123456789101112131415161718192021222324252627282930313233343536 |
- using Microsoft.AspNetCore.Http;
- using NPOI.SS.Formula.Functions;
- using System;
- using System.Threading.Tasks;
- namespace Ropin.Inspection.Api.Filters
- {
- /// <summary>
- /// 请求记录中间件
- /// </summary>
- 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);
- }
- }
- }
|