public static IServiceCollection ConfigureHttpClient(this IServiceCollection services) { services.AddHttpClient <IHttpClient, StandardHttpClient>() .AddPolicyHandler(HttpPolicy.GetRetryPolicy()) .AddPolicyHandler(HttpPolicy.GetCircuitBreakerPolicy()); return(services); }
public static IHttpClientBuilder AddPolicies( this IHttpClientBuilder clientBuilder, IConfiguration configuration ) { var policyOptions = configuration.Get <PolicyOptions>(); return(clientBuilder.AddPolicyHandler(HttpPolicy.GetTimeout(policyOptions.Timeout)) .AddPolicyHandler(HttpPolicy.GetRetryPolicy(policyOptions.HttpRetry)) .AddPolicyHandler(HttpPolicy.GetCircuitBreakerPolicy(policyOptions.HttpCircuitBreaker))); }