feat(shared-web): add shared swagger and tracing utilities

This commit is contained in:
2025-11-22 21:20:49 +08:00
parent b9d4a06f61
commit b587e8c1e1
22 changed files with 1058 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Http;
namespace TakeoutSaaS.Shared.Web.Middleware;
/// <summary>
/// 安全响应头中间件
/// </summary>
public sealed class SecurityHeadersMiddleware
{
private readonly RequestDelegate _next;
public SecurityHeadersMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task InvokeAsync(HttpContext context)
{
var headers = context.Response.Headers;
headers["X-Content-Type-Options"] = "nosniff";
headers["X-Frame-Options"] = "DENY";
headers["X-XSS-Protection"] = "1; mode=block";
headers["Referrer-Policy"] = "no-referrer";
await _next(context);
}
}