V13-FE-006: consolidate approved UI and contract hardening
deploy / deploy (push) Successful in 1m52s
deploy / notify (push) Successful in 1s

This commit is contained in:
2026-08-13 02:41:00 +09:00
parent d79edae546
commit 3f293d8aa8
1278 changed files with 14384 additions and 1664 deletions
@@ -0,0 +1,34 @@
using System.Diagnostics;
namespace KArtSell.Host.Infrastructure;
/// <summary>
/// Establishes one correlation identifier at the HTTP boundary.
/// Endpoint code may use TraceIdentifier or Items[CorrelationId], but both resolve
/// to the same value and the response exposes it for support/replay tracing.
/// </summary>
public sealed class CorrelationIdMiddleware(RequestDelegate next, ILogger<CorrelationIdMiddleware> logger)
{
public async Task InvokeAsync(HttpContext context)
{
var correlationId = ReadCorrelationId(context.Request.Headers["X-Correlation-Id"]);
context.TraceIdentifier = correlationId.ToString("D");
context.Items["CorrelationId"] = correlationId;
context.Response.Headers["X-Correlation-Id"] = correlationId.ToString("D");
Activity.Current?.SetTag("kartsell.correlation_id", correlationId.ToString("D"));
using (logger.BeginScope(new Dictionary<string, object?>
{
["CorrelationId"] = correlationId,
}))
{
await next(context);
}
}
private static Guid ReadCorrelationId(string? headerValue) =>
Guid.TryParse(headerValue, out var correlationId) && correlationId != Guid.Empty
? correlationId
: Guid.NewGuid();
}