feat(api, domain, core): Глобальные модели ошибок. ConfigureValidator - валидатор контроллеров. GlobalExceptionHandler - глобальный обработчик ошибок в API.

This commit is contained in:
Mikhail Trubnikov
2026-05-19 16:19:55 +10:00
parent c0148088c1
commit d8af0253b1
10 changed files with 236 additions and 33 deletions

View File

@@ -2,6 +2,7 @@ using Elastic.CommonSchema.Serilog;
using FluentValidation;
using Microsoft.AspNetCore.HttpOverrides;
using PARR.API.Authentication;
using PARR.API.Infrastructure;
using PARR.API.Installers;
using PARR.API.Settings;
using PARR.Core;
@@ -68,10 +69,11 @@ builder.Services.Configure<ForwardedHeadersOptions>(options =>
});
builder.Services.AddHttpContextAccessor();
builder.Services.AddValidatorServices();
//builder.Services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly());
//builder.Services.AddControllers();
builder.Services.AddControllers();
builder.Services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly());
builder.Services.AddHttpContextAccessor();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
@@ -82,6 +84,9 @@ builder.Services.InstallCorsServices();
var app = builder.Build();
// подключаем обработку моих кастомных Exceptions (GlobalExceptionHandler)
app.UseExceptionHandler();
// При использовании балансировщика (haproxy, перенаправлять заголовки)
app.UseForwardedHeaders();