MinimalApis.Extensions
MinimalApis.Extensions copied to clipboard
Support a wrapper type for binding to parameters from form values
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
.