Open rfvgyhn opened 2 years ago
This is because the name of the parameter is lost through in the F# function conversions (as you've pointed out).
cc @dsyme
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
As a workaround you can also use wrapper with AsParametersAttribute
public static class Endpoint
{
public static Delegate Of<TParam, TResult>(FSharpFunc<TParam, TResult> requestDelegate)
{
return (HttpContext context, [AsParametersAttribute] TParam parameters) => requestDelegate.Invoke(parameters);
}
}
And then from F#
app.MapGet("/{name}", Endpoint.Of (fun (req : {| Name : string |}) -> $"Hello {req.Name}!"))
I've made simplistic library for this https://github.com/mchylek/Endpoints.FSharp.Interop
Mapping a route with a route value in F# fails to bind the value when using a named function instead of a anonymous function. I'm not sure if this is an ASP.NET or F# issue (or maybe just a consequence of how F# works with the delegate param).
dotnet new web -lang F#
dotnet run