using Microsoft.AspNetCore.Builder;
using TakeoutSaaS.Shared.Web.Middleware;

namespace TakeoutSaaS.Shared.Web.Extensions;

/// <summary>
/// Web 应用中间件扩展。
/// </summary>
public static class ApplicationBuilderExtensions
{
    /// <summary>
    /// 按规范启用 TraceId、请求日志、异常映射与安全响应头。
    /// </summary>
    public static IApplicationBuilder UseSharedWebCore(this IApplicationBuilder app)
    {
        app.UseMiddleware<CorrelationIdMiddleware>();
        app.UseMiddleware<RequestLoggingMiddleware>();
        app.UseMiddleware<ExceptionHandlingMiddleware>();
        app.UseMiddleware<SecurityHeadersMiddleware>();
        return app;
    }
}
