Skip to content

Instantly share code, notes, and snippets.

@christiannagel
Created June 8, 2018 08:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christiannagel/74dcd6b8cda7bd30817cc9aad0c40b9f to your computer and use it in GitHub Desktop.
Save christiannagel/74dcd6b8cda7bd30817cc9aad0c40b9f to your computer and use it in GitHub Desktop.
Add a HttpClientHandler to a HTTP Client Factory configuration
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();
}
@wangengzheng
Copy link

good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment