public void InstallServices(IServiceCollection services, IConfiguration configuration) { var neverBounceSettings = new NeverBounceSetting(); configuration.GetSection(nameof(NeverBounceSetting)).Bind(neverBounceSettings); if (!services.Any(x => x.ServiceType == typeof(NeverBounceSetting))) { services.AddSingleton(neverBounceSettings); } services.AddTransient <INeverBounceGateway, NeverBounceGateway>(); services.AddTransient <IAWSGateway, AWSGateway>(); services.AddTransient <ITwilioGateway, TwilioGateway>(); services.AddTransient <IGatewayFactory, GatewayFactory>(); services.AddHttpClient("bounce", c => { ConfigureBounceHttpClient(c, neverBounceSettings); }); }
private void ConfigureBounceHttpClient(HttpClient client, NeverBounceSetting settings) { client.BaseAddress = new Uri($"{settings.Host}/{settings.Version}/"); }