mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-30 18:52:50 +08:00
25 lines
761 B
C#
25 lines
761 B
C#
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Ocelot.Library.Middleware
|
|
{
|
|
public class RequestLoggerMiddleware
|
|
{
|
|
private readonly RequestDelegate _next;
|
|
private readonly ILogger _logger;
|
|
|
|
public RequestLoggerMiddleware(RequestDelegate next, ILoggerFactory loggerFactory)
|
|
{
|
|
_next = next;
|
|
_logger = loggerFactory.CreateLogger<RequestLoggerMiddleware>();
|
|
}
|
|
|
|
public async Task Invoke(HttpContext context)
|
|
{
|
|
_logger.LogInformation("Handling request: " + context.Request.Path);
|
|
await _next.Invoke(context);
|
|
_logger.LogInformation("Finished handling request.");
|
|
}
|
|
}
|
|
} |