using Microsoft.AspNetCore.Http; using NPOI.SS.Formula.Functions; using System; using System.Threading.Tasks; namespace Ropin.Inspection.Api.Filters { /// /// 请求记录中间件 /// public class RequestMiddleware { private readonly RequestDelegate _next; private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(RequestMiddleware)); public RequestMiddleware(RequestDelegate next) { this._next = next; } public RequestMiddleware() { } public async Task Invoke(HttpContext httpContext) { //启用读取request httpContext.Request.EnableBuffering(); var request = httpContext.Request; //请求接口 var reqUrl = request.Path; // Console.WriteLine(reqUrl); log.Info($"路径3:{reqUrl}"); await _next(httpContext); } } }