Closed
Description
Is your feature request related to a problem? Please describe.
I am trying to use a custom model binder in the new minimal APIs but it does not seem that this is possible at the moment.
In the controller based approach I could create a custom binder as such
public class CustomBinder<TEvent> : IModelBinder { ... }
public class CustomBinderProvider : IModelBinderProvider { ... }
and register it in Startup.ConfigureServices
services.AddControllers(options =>
{
options.ModelBinderProviders.Insert(0, new CustomBinderProvider());
});
and then use it
[HttpPost("foo-endpoint")]
public IActionResult Post(Foo customType) => Ok();
Where the CustomBinderProvider
would react to the Foo
and use the CustomBinder
.
Describe the solution you'd like
Using a custom model binding in the minimal API setup so it's possible to do the same as described above, or achieve the same result.
app.MapPost("foo-endpoint", (Foo customType) => "ok");