CarterCommunity / Carter

Carter is framework that is a thin layer of extension methods and functionality over ASP.NET Core allowing code to be more explicit and most importantly more enjoyable.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for registering an endpoint filter using an endpoint filter factory

ergonzalez-boh opened this issue · comments

Currently, Carter provides the ability to register endpoint filters through the CarterModule Before and After delegates. However, there is no built-in mechanism to incorporate an EndpointFilterFactory that would allow dynamic determination of whether an endpoint filter should be added to a specific endpoint during startup.

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis/min-api-filters?view=aspnetcore-7.0#register-a-filter-using-an-endpoint-filter-factory

Hello @ergonzalez-boh

RouteGroupBuilder root = app.MapGroup("/api");
root.MapCarter();
root.AddEndpointFilterFactory(ValidationFilter.ValidationFilterFactory);

Can't you solve it with that?