Middleware
Code that runs on every request, in order, around your endpoints.
What is Middleware?
Middleware is code that runs on every request, in order, before and after your endpoint, like security checks at an airport. Logging, HTTPS redirection, authentication and error handling are all middleware.
app.Use(async (context, next) =>
{
var started = Stopwatch.GetTimestamp();
await next(context);
app.Logger.LogInformation("{Path} took {Ms} ms", context.Request.Path, Stopwatch.GetElapsedTime(started).TotalMilliseconds);
});
Level: Journeyman · More ASP.NET Core terms at this level
Updated