Add a HttpClientHandler to a HTTP Client Factory configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private ServiceProvider ConfigureServices() | |
{ | |
var services = new ServiceCollection(); | |
services.AddLogging(builder => | |
{ | |
builder.AddFilter((category, level) => true); | |
builder.AddConsole(options => options.IncludeScopes = true); | |
}); | |
services.AddHttpClient("cni", client => | |
{ | |
client.BaseAddress = new Uri("https://www.cninnovation.com"); | |
}).ConfigureHttpMessageHandlerBuilder(config => new HttpClientHandler | |
{ | |
AutomaticDecompression = DecompressionMethods.GZip | |
}).AddTypedClient<Client>(); | |
return services.BuildServiceProvider(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
good