public static void RegisterServices(this IServiceCollection services) { services.AddSingleton <IValidationAttributeAdapterProvider, CpfValidationAttributeAdapterProvider>(); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddScoped <IAspNetUser, AspNetUser>(); #region HttpServices services.AddTransient <HttpClientAuthorizationDelegatingHandler>(); services.AddHttpClient <IAutenticacaoService, AutenticacaoService>() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); services.AddHttpClient <ICatalogoService, CatalogoService>() .AddHttpMessageHandler <HttpClientAuthorizationDelegatingHandler>() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); services.AddHttpClient <IComprasBffService, ComprasBffService>() .AddHttpMessageHandler <HttpClientAuthorizationDelegatingHandler>() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); #endregion }
public static void RegisterServices(this IServiceCollection services, IConfiguration configuration) { services.AddSingleton <IValidationAttributeAdapterProvider, CpfValidationAttributeAdapterProvider>(); services.AddTransient <HttpClientAuthorizationDelegatingHandler>(); // pq trasiente, pq chama uma estancia de cada vez services.AddHttpClient <IAutenticacaoService, AutenticacaoService>(); services.AddHttpClient <ICatalogoService, CatalogoService>() .AddHttpMessageHandler <HttpClientAuthorizationDelegatingHandler>() //.AddTransientHttpErrorPolicy( //p => p.WaitAndRetryAsync(3, _ => TimeSpan.FromMilliseconds(600))); .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); //porque singleton, porque tenho que estudar services.AddScoped <IUser, AspNetUser>(); //adicionar via scoped, fica limitado ao request #region Refit //services.AddHttpClient("Refit", // options => // { // options.BaseAddress = new Uri(configuration.GetSection("CatalogoUrl").Value); // }) // .AddHttpMessageHandler<HttpClientAuthorizationDelegatingHandler>() // .AddTypedClient(Refit.RestService.For<ICatalogoServiceRefit>); #endregion }
public static void RegisterServices(this IServiceCollection services) { services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddScoped <IAspNetUser, AspNetUser>(); services.AddTransient <HttpClientAuthorizationDelegatingHandler>(); services.AddHttpClient <ICatalogoService, CatalogoService>() .AddHttpMessageHandler <HttpClientAuthorizationDelegatingHandler>() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); services.AddHttpClient <ICarrinhoService, CarrinhoService>() .AddHttpMessageHandler <HttpClientAuthorizationDelegatingHandler>() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); services.AddHttpClient <IPedidoService, PedidoService>() .AddHttpMessageHandler <HttpClientAuthorizationDelegatingHandler>() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); services.AddHttpClient <IClienteService, ClienteService>() .AddHttpMessageHandler <HttpClientAuthorizationDelegatingHandler>() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); }
public static void RegisterServices(this IServiceCollection services, IConfiguration configuration) { services.AddSingleton <IValidationAttributeAdapterProvider, CpfValidationAttributeAdapterProvider>(); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddScoped <IAspNetUser, AspNetUser>(); services.AddTransient <HttpClientAutorizationDelegatingHandler>(); services.AddHttpClient <IAutenticacaoService, AutenticacaoService>() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy(p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); services.AddHttpClient <ICatalogoService, CatalogoService>() .AddHttpMessageHandler <HttpClientAutorizationDelegatingHandler>() // .AddTransientHttpErrorPolicy(p => p.WaitAndRetryAsync(retryCount: 3, sleepDurationProvider: _=> TimeSpan.FromMilliseconds(600))); .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy(p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); services.AddHttpClient <IComprasBffService, ComprasBffService>() .AddHttpMessageHandler <HttpClientAutorizationDelegatingHandler>() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy(p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); #region Refit config //services.AddHttpClient("Refit", options => { // options.BaseAddress = new Uri(configuration.GetSection("CatalogoUrl").Value); //}).AddHttpMessageHandler<HttpClientAutorizationDelegatingHandler>() //.AddTypedClient(Refit.RestService.For<ICatalogoService>); #endregion }
private static IServiceCollection ResolveHttpServices(this IServiceCollection services) { services.AddHttpClient <IAuthenticationFacade, AuthenticationFacade>() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy(x => x.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); return(services); }
public static void RegisterServices(this IServiceCollection services, IConfiguration configuration) { services.AddSingleton <IValidationAttributeAdapterProvider, CpfValidationAttributeAdapterProvider>(); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddScoped <IAspNetUser, AspNetUser>(); #region HttpServices services.AddTransient <HttpClientAuthorizationDelegatingHandler>(); services.AddHttpClient <IAutenticacaoService, AutenticacaoService>() .AllowSelfSignedCertificate() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(1, TimeSpan.FromSeconds(30))); services.AddHttpClient <ICatalogoService, CatalogoService>() .AllowSelfSignedCertificate() .AddHttpMessageHandler <HttpClientAuthorizationDelegatingHandler>() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(1, TimeSpan.FromSeconds(30))); services.AddHttpClient <IComprasBffService, ComprasBffService>() .AllowSelfSignedCertificate() .AddHttpMessageHandler <HttpClientAuthorizationDelegatingHandler>() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(1, TimeSpan.FromSeconds(30))); services.AddHttpClient <IClienteService, ClienteService>() .AllowSelfSignedCertificate() .AddHttpMessageHandler <HttpClientAuthorizationDelegatingHandler>() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(1, TimeSpan.FromSeconds(30))); #endregion //services.AddHttpClient("Refit", options => //{ // options.BaseAddress = new Uri(configuration.GetSection("CatalogoUrl").Value); //}) // .AddHttpMessageHandler<HttpClientAuthorizationDelegatingHandler>() // .AddTypedClient(Refit.RestService.For<ICatalogoServiceRefit>); }
public static void RegisterServices(this IServiceCollection services) { services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddScoped <IAspNetUser, AspNetUser>(); services.AddScoped <ICacheService, CacheService>(); services.AddTransient <HttpClientAuthorizationDelegatingHandler>(); services.AddHttpClient <IUsuarioService, UsuarioService>() .AddHttpMessageHandler <HttpClientAuthorizationDelegatingHandler>() .AllowSelfSignedCertificate() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); services.AddHttpClient <ISaemService, SaemService>() .AddHttpMessageHandler <HttpClientAuthorizationDelegatingHandler>() .AllowSelfSignedCertificate() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); services.AddHttpClient <ISafimService, SafimService>() .AddHttpMessageHandler <HttpClientAuthorizationDelegatingHandler>() .AllowSelfSignedCertificate() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); services.AddHttpClient <ISasciService, SasciService>() .AddHttpMessageHandler <HttpClientAuthorizationDelegatingHandler>() .AllowSelfSignedCertificate() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); services.AddHttpClient <ISturService, SturService>() .AddHttpMessageHandler <HttpClientAuthorizationDelegatingHandler>() .AllowSelfSignedCertificate() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); }
public static void RegisterServices(this IServiceCollection services, IConfiguration configuration) { services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddSingleton <IValidationAttributeAdapterProvider, MoedaValidationAttributeAdapterProvider>(); #region HttpServices services.AddHttpClient <ITaxaService, TaxaService>() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AllowSelfSignedCertificate() .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); services.AddHttpClient <IJurosService, JurosService>() .AddPolicyHandler(PollyExtensions.EsperarTentar()) .AllowSelfSignedCertificate() .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); #endregion }