From 236e40857fa47212446b96bfdfcdc259507d356d Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Mon, 5 Aug 2024 15:39:04 +0200 Subject: [PATCH] refactor: ConfigureWebApiExtensionsEnd entfernen und direkt in Program.cs konfigurieren --- StaffDBServer/Program.cs | 12 ++++++++- .../SharedExtensions/ServiceExtensions.cs | 27 ------------------- 2 files changed, 11 insertions(+), 28 deletions(-) delete mode 100644 StaffDBServer/_Shared/SharedExtensions/ServiceExtensions.cs diff --git a/StaffDBServer/Program.cs b/StaffDBServer/Program.cs index c8da799..28e1ac0 100644 --- a/StaffDBServer/Program.cs +++ b/StaffDBServer/Program.cs @@ -22,6 +22,7 @@ using NSwag.Generation.Processors.Security; using NSwag; using System.Linq; using Microsoft.Extensions.PlatformAbstractions; +using Microsoft.AspNetCore.Mvc; AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs) => { @@ -117,7 +118,16 @@ try builder.Services.AddScoped(); builder.Services.AddJwtManagerWithLdap(configuration.GetSection("LdapOptions")); - builder.Services.ConfigureWebApiExtensionsEnd(); // should come last + // should come last + builder.Services.AddMvc() + .ConfigureApiBehaviorOptions(options => + { + options.InvalidModelStateResponseFactory = context => + { + var errors = new HRD.WebApi.Helpers.HttpErrorDetails(context); + return new BadRequestObjectResult(errors); + }; + }); var app = builder.Build(); diff --git a/StaffDBServer/_Shared/SharedExtensions/ServiceExtensions.cs b/StaffDBServer/_Shared/SharedExtensions/ServiceExtensions.cs deleted file mode 100644 index 384e39c..0000000 --- a/StaffDBServer/_Shared/SharedExtensions/ServiceExtensions.cs +++ /dev/null @@ -1,27 +0,0 @@ -using HRD.AppLogger; -using HRD.LDAPService.JWT; -using HRD.WebApi.DAL.Middleware; -using HRD.WebApi.Helpers; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Server.IISIntegration; -using Microsoft.Extensions.DependencyInjection; - -namespace StaffDBServer.SharedExtensions -{ - public static class ServiceExtensions - { - public static void ConfigureWebApiExtensionsEnd(this IServiceCollection services) - { - services.AddMvc() - .ConfigureApiBehaviorOptions(options => - { - options.InvalidModelStateResponseFactory = context => - { - var errors = new HRD.WebApi.Helpers.HttpErrorDetails(context); - return new BadRequestObjectResult(errors); - }; - }); - } - } -} \ No newline at end of file