public async Task InvokeAsync(HttpContext httpContext)
{
httpContext.Request.Headers.TryGetValue("x-correlation-id", out StringValues correlationIds);
var correlationId = correlationIds.FirstOrDefault() ?? Guid.NewGuid().ToString();
httpContext.Response.Headers.Add("x-correlation-id", correlationId.ToString());
//using (LogContext.PushProperty("CorrelationId", correlationId.ToString()))
//{
// context
// .Response
// .OnStarting(
// state =>
// {
// var httpContext = (HttpContext)state;
// httpContext.Response.Headers.Add("x-correlation-id", correlationId.ToString());
// var keysName = string.Join(",", httpContext.Response.Headers.Keys);
// httpContext.Response.Headers.Add("Access-Control-Expose-Headers", keysName);
// return Task.CompletedTask;
// },
// httpContext
// );
// await _next(httpContext);
//}
await _next(httpContext);
}
}