forked from mtusi2026/mtusi2026lab2
ЛР 2: PostgreSQL, сессии, Redis и исследование
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
namespace Messenger.Api.Middleware;
|
||||
|
||||
public sealed class RequestIdMiddleware
|
||||
{
|
||||
private readonly RequestDelegate _next;
|
||||
|
||||
public RequestIdMiddleware(RequestDelegate next) => _next = next;
|
||||
|
||||
public async Task InvokeAsync(HttpContext context)
|
||||
{
|
||||
var requestId = Guid.NewGuid().ToString();
|
||||
context.Items["RequestId"] = requestId;
|
||||
context.Response.Headers["X-Request-Id"] = requestId;
|
||||
await _next(context);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user