From e4b94decb23cb8f9da977cba2d48af6458c7e349 Mon Sep 17 00:00:00 2001 From: Reuben Bond Date: Mon, 8 May 2023 16:46:23 -0700 Subject: [PATCH] Use Services.Common in WebhookClient --- src/Web/WebhookClient/Extensions/Extensions.cs | 2 -- src/Web/WebhookClient/GlobalUsings.cs | 3 +-- src/Web/WebhookClient/Program.cs | 15 ++------------- src/Web/WebhookClient/WebhookClient.csproj | 4 ++++ 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/Web/WebhookClient/Extensions/Extensions.cs b/src/Web/WebhookClient/Extensions/Extensions.cs index c23684142..963d60073 100644 --- a/src/Web/WebhookClient/Extensions/Extensions.cs +++ b/src/Web/WebhookClient/Extensions/Extensions.cs @@ -35,9 +35,7 @@ internal static class Extensions public static IServiceCollection AddHttpClientServices(this IServiceCollection services, IConfiguration configuration) { - services.AddSingleton(); services.AddTransient(); - services.AddHttpClient("extendedhandlerlifetime").SetHandlerLifetime(Timeout.InfiniteTimeSpan); //add http client services services.AddHttpClient("GrantClient") diff --git a/src/Web/WebhookClient/GlobalUsings.cs b/src/Web/WebhookClient/GlobalUsings.cs index 0ab3bbad1..ce30779dc 100644 --- a/src/Web/WebhookClient/GlobalUsings.cs +++ b/src/Web/WebhookClient/GlobalUsings.cs @@ -3,7 +3,6 @@ global using Microsoft.AspNetCore.Authentication.Cookies; global using Microsoft.AspNetCore.Authentication.OpenIdConnect; global using Microsoft.AspNetCore.Authorization; global using Microsoft.AspNetCore.Mvc; -global using System.Security.Claims; global using System.Threading.Tasks; global using Microsoft.Extensions.Logging; global using Microsoft.Extensions.Options; @@ -17,7 +16,7 @@ global using System.Text.Json; global using Microsoft.AspNetCore.Http; global using System.Net.Http.Headers; global using System.Threading; -global using Microsoft.AspNetCore; +global using Services.Common; global using Microsoft.AspNetCore.Hosting; global using WebhookClient; global using Microsoft.AspNetCore.Builder; diff --git a/src/Web/WebhookClient/Program.cs b/src/Web/WebhookClient/Program.cs index 977fa4243..48fbd433d 100644 --- a/src/Web/WebhookClient/Program.cs +++ b/src/Web/WebhookClient/Program.cs @@ -1,5 +1,6 @@ var builder = WebApplication.CreateBuilder(args); +builder.AddServiceDefaults(); builder.Services.AddSession(opt => { opt.Cookie.Name = ".eShopWebhooks.Session"; @@ -12,18 +13,7 @@ builder.Services.AddSession(opt => .AddMvc(); builder.Services.AddControllers(); var app = builder.Build(); - -var pathBase = app.Configuration["PATH_BASE"]; -if (!string.IsNullOrEmpty(pathBase)) -{ - app.UsePathBase(pathBase); -} - -if (!app.Environment.IsDevelopment()) -{ - app.UseExceptionHandler("/Error"); - // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. -} +app.UseServiceDefaults(); app.Map("/check", capp => { @@ -62,7 +52,6 @@ app.UseCookiePolicy(new CookiePolicyOptions { MinimumSameSitePolicy = SameSiteMo app.UseStaticFiles(); app.UseSession(); -app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.MapDefaultControllerRoute(); diff --git a/src/Web/WebhookClient/WebhookClient.csproj b/src/Web/WebhookClient/WebhookClient.csproj index 53649d576..82bcf6edc 100644 --- a/src/Web/WebhookClient/WebhookClient.csproj +++ b/src/Web/WebhookClient/WebhookClient.csproj @@ -17,4 +17,8 @@ + + + +