using AipGateway.API.Application.Modules; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; namespace AipGateway.API.Application.Pipeline.Middlewares.Behaviours { public class ApiGuidGeneratorBehaviour { private readonly ILogger _log; private readonly RequestDelegate _next; public ApiGuidGeneratorBehaviour(ILogger logger, RequestDelegate next) { _log = logger; _next = next; _log.LogError("wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww: ApiGuidGeneratorMiddleware"); } public async Task InvokeAsync(HttpContext context) { _log.LogError("wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww: ApiGuidGeneratorMiddleware, {0}, {1}", context.Connection.RemoteIpAddress, context.Request.Path); string requestUrl = context.Request.Path; if (requestUrl.Contains(GlobalConstants.API_ENDPOINT)) { string guid = Guid.NewGuid().ToString(); //context.Items.Add(GlobalConstants.API_GUID, guid); context.Items[GlobalConstants.API_GUID] = guid; } await _next(context); await Task.FromResult(Task.CompletedTask); return; } } }