Add ExceptionHandlingMiddleware to request pipeline

Refactor `using` directives in `Program.cs` to include `ReC.API.Middleware` for middleware functionality.

Introduce `ExceptionHandlingMiddleware` to the HTTP request pipeline to handle exceptions globally. Suppress CS0618 warnings for its usage. No changes were made to the existing controller service configuration.
This commit is contained in:
tekh 2025-12-03 09:34:49 +01:00
parent d239d43c1c
commit 4d593e8a8e

View File

@ -1,6 +1,7 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using ReC.Infrastructure; using ReC.API.Middleware;
using ReC.Application; using ReC.Application;
using ReC.Infrastructure;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
@ -30,6 +31,10 @@ builder.Services.AddSwaggerGen();
var app = builder.Build(); var app = builder.Build();
#pragma warning disable CS0618
app.UseMiddleware<ExceptionHandlingMiddleware>();
#pragma warning restore CS0618
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment()) if (app.Environment.IsDevelopment())
{ {