using AipGateway.API.Application; namespace AipGateway.API.Middlewares { public class ApiGuidGeneratorBehaviour { private readonly ILogger _log; private readonly RequestDelegate _next; public ApiGuidGeneratorBehaviour(ILogger log, RequestDelegate next) { _log = log; _next = next; } public async Task InvokeAsync(HttpContext context) { string requestUrl = context.Request.Path; if (requestUrl.Contains(GlobalConstants.API_PREFIX)) { string guid = Guid.NewGuid().ToString(); context.Items[GlobalConstants.API_GUID] = guid; context.Items[GlobalConstants.API_START_TM] = DateTime.Now; } await _next(context); return; } } }