1 minutes reading time (41 words)
Featured

Copy of Test local blog

var builder = WebApplication.CreateBuilder(args);

var app = builder.Build();

string ColorName(string color) => $"Color specified: {color}!";

app.MapGet("/colorSelector/{color}", ColorName)
.AddEndpointFilter(async (invocationContext, next) =>
{
var color = invocationContext.GetArgument<string>(0);

if (color == "Red")
{
return Results.Problem("Red not allowed!");
}
return await next(invocationContext);
});

app.Run();

Comments (0)
There are no comments posted here yet