MinimalApis.Extensions icon indicating copy to clipboard operation
MinimalApis.Extensions copied to clipboard

Support a wrapper type for binding to parameters from form values

Open DamianEdwards opened this issue 2 years ago • 0 comments

e.g.

app.MapPost("/todos", (FormData<Todo> form) =>
{
    var todo = form.Value;
    // Do something with your todo here
});

public record Todo(int Id, string Title, bool IsComplete);

Can do this using MVC's binder via ModelBinder<T> now but obviously it uses MVC under the covers. A lighter weight option could be nice, although I'd need to decide how much of MVCs behavior to replicate and it's pretty complicated. Perhaps we could borrow some logic from the Options<T> configuration binding in Microsoft.Extensions.

DamianEdwards avatar Mar 22 '22 00:03 DamianEdwards