Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public ESenderService(HttpClient httpClient, IOptions<UrlsConfig> config)
}
public async Task<MailRequestViewModel> AddAsync(MailRequestViewModel model, CancellationToken ct)
{
var response = await _httpClient.PostAsJsonAsync(_config.Value.ESenderUrl+"/api/emailsender",model,ct);
var response = await _httpClient.PostAsJsonAsync("api/emailsender",model,ct);
return await response.Content.ReadAsAsync<MailRequestViewModel>(ct);
}

public async Task<MailRequestViewModel> GetAsync(long id, CancellationToken ct)
{
var response = await _httpClient.GetAsync(_config.Value.ESenderUrl+$"/api/emailsender/{id}",ct);
var response = await _httpClient.GetAsync($"api/emailsender/{id}",ct);
return await response.Content.ReadAsAsync<MailRequestViewModel>(ct);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Extensions.Http.Polly">
<Version>2.2.0</Version>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IdentityModel.Tokens.Jwt;
using System;
using System.IdentityModel.Tokens.Jwt;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
Expand All @@ -7,6 +8,7 @@
using Microsoft.Extensions.DependencyInjection;
using O2NextGen.Web.BFF.Core.Config;
using O2NextGen.Web.BFF.Core.Features.E_Sender.Services;
using Polly;

namespace O2NextGen.Web.BFF.Core
{
Expand All @@ -22,7 +24,7 @@ public Startup(IConfiguration configuration)
public void ConfigureServices(IServiceCollection services)
{
services.AddCustomMvc(Configuration);
services.AddApplicationServices();
services.AddApplicationServices(Configuration);
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
Expand Down Expand Up @@ -69,15 +71,20 @@ public static IServiceCollection AddCustomAuthentication(this IServiceCollection

return services;
}
public static IServiceCollection AddApplicationServices(this IServiceCollection services)
public static IServiceCollection AddApplicationServices(this IServiceCollection services,IConfiguration configuration)
{
//register delegating handlers
// services.AddTransient<HttpClientAuthorizationDelegatingHandler>();
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

//register http services
services
.AddHttpClient<IESenderService, ESenderService>();
.AddHttpClient<IESenderService, ESenderService>("E-Sender",client =>
{
client.BaseAddress = new Uri(configuration.GetValue<string>("urls:ESenderUrl"));
})
.AddTransientHttpErrorPolicy(builder => builder.WaitAndRetryAsync(5,arrempt=>TimeSpan.FromSeconds(arrempt*2)
));

return services;
}
Expand Down