dotnet-websharper / core

WebSharper - Full-stack, functional, reactive web apps and microservices in F# and C#
https://websharper.com
Apache License 2.0
593 stars 52 forks source link

Query parameters in EndPoints #1340

Closed granicz closed 1 year ago

granicz commented 1 year ago

Currently, one can use the Query attribute to designate that some of the endpoint arguments should be obtained/parsed from query params:

// FindBook?isbn=9781484207413
// FindBook?isbn=9781484207413&ty=paperback
| [<Query "isbn", "ty">] FindBook of isbn:string * ty:string option

However, there is no reason why the same information couldn't be encoded into EndPoint values, in fact, Bolero, which shares the same routing capabilities as WebSharper, recently introduced (see relevant PR):

// FindBook?isbn=9781484207413
// FindBook?isbn=9781484207413&ty=paperback
| [<EndPoint "/FindBook?isbn={isbn}&ty={ty}">] FindBook of isbn:string * ty:string option

This ticket is for the work involved in carrying over Bolero's enhancement to WebSharper routing, with the following extras that need further attention: