mirror of
https://github.com/Jetsparrow/jetherald.git
synced 2026-01-21 07:56:09 +03:00
19 lines
468 B
C#
19 lines
468 B
C#
using System.Diagnostics;
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
namespace JetHerald.Middlewares;
|
|
public class RequestTimeFeature
|
|
{
|
|
public RequestTimeFeature() => Stopwatch = Stopwatch.StartNew();
|
|
public Stopwatch Stopwatch { get; }
|
|
}
|
|
|
|
public class RequestTimeTrackerMiddleware : IMiddleware
|
|
{
|
|
public Task InvokeAsync(HttpContext context, RequestDelegate next)
|
|
{
|
|
context.Features.Set(new RequestTimeFeature());
|
|
return next(context);
|
|
}
|
|
}
|