From 4061c06d009506c9266d0ec523810f17619347c8 Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Thu, 22 Sep 2022 16:42:19 -1000 Subject: [PATCH] add new snippet (#68) --- .../problem-details-service/Program.cs | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/fundamentals/middleware/problem-details-service/Program.cs b/fundamentals/middleware/problem-details-service/Program.cs index 9eb34dc..d2ffc12 100644 --- a/fundamentals/middleware/problem-details-service/Program.cs +++ b/fundamentals/middleware/problem-details-service/Program.cs @@ -1,4 +1,4 @@ -#define API_CONTROLLER // MIDDLEWARE API_CONTROLLER API_CONT_SHORT DEFAULT +#define DISABLE // MIDDLEWARE API_CONTROLLER API_CONT_SHORT DEFAULT DISABLE #if NEVER #elif MIDDLEWARE // @@ -169,7 +169,6 @@ app.MapControllers(); app.Run(); // - #elif MIN_API // var builder = WebApplication.CreateBuilder(args); @@ -245,4 +244,24 @@ app.MapGet("/squareroot", (HttpContext context, double radicand) => app.Run(); // +#elif DISABLE +// +var builder = WebApplication.CreateBuilder(args); + +builder.Services.AddControllers() + .ConfigureApiBehaviorOptions(options => + { + options.SuppressMapClientErrors = true; + }); + +var app = builder.Build(); + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); +// #endif