You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
650 B
C#
27 lines
650 B
C#
using Microsoft.AspNetCore.Http;
|
|
|
|
namespace Ds.WMS.WebCore
|
|
{
|
|
/// <summary>
|
|
/// 请求中间件 用于记录请求信息
|
|
/// </summary>
|
|
public class RequestLoggingMiddleware
|
|
{
|
|
private readonly RequestDelegate _next;
|
|
|
|
public RequestLoggingMiddleware(RequestDelegate next)
|
|
{
|
|
_next = next;
|
|
}
|
|
|
|
public async Task InvokeAsync(HttpContext context)
|
|
{
|
|
// 记录请求信息
|
|
Console.WriteLine($"Request: {context.Request.Method} {context.Request.Path}");
|
|
|
|
// 调用下一个中间件
|
|
await _next(context);
|
|
}
|
|
}
|
|
}
|