Endpoint Filter
Code that runs around specific minimal API handlers.
What is Endpoint Filter?
An endpoint filter runs code before and after a minimal API handler, for checks like validation or logging on just some endpoints.
app.MapPost("/recipes", Create)
.AddEndpointFilter(async (ctx, next) =>
{
var recipe = ctx.GetArgument<NewRecipe>(0);
return string.IsNullOrWhiteSpace(recipe.Title) ? Results.BadRequest("Title is required") : await next(ctx);
});
Level: Journeyman · More ASP.NET Core terms at this level
Updated