在控制台打印请求信息

This commit is contained in:
qianhao.xu
2024-12-18 16:49:32 +08:00
parent 807b318ce8
commit 205fda9480

View File

@@ -100,6 +100,18 @@ if (app.Environment.IsDevelopment())
workId += 1;
}
SnowFlakeSingle.WorkId = workId;
//在控制台打印请求信息
app.Use(async (context, next) =>
{
Console.WriteLine($"Request: {context.Request.Method} {context.Request.Path}");
// 调用下一个中间件
await next();
// 如果需要在响应后打印信息,可以在这里进行
Console.WriteLine($"Response: {context.Response.StatusCode}");
});
//使用全局异常中间件
app.UseMiddleware<GlobalExceptionMiddleware>();