I have a web service with a hello world endpoint like this:
let app =
choose [
GET >=>
choose [
path "/hello" >=> OK "Hello World!"
pathScan "/hello/%s" (fun name -> OK (sprintf "Hello World from %s" name)) ]
NOT_FOUND "Not found" ]
[<EntryPoint>]
let main argv =
startWebServer defaultConfig app
0
Now I would like to add an additional endpoint which can handle routes like this:
http://localhost:8083/hello/{name}?lang={lang}
This route should work for the following URLs:
- http://localhost:8083/hello/FooBar In this case lang should be set to a default value of "en-GB"
- http://localhost:8083/hello/FooBar?lang=en-GB
- http://localhost:8083/hello/FooBar?lang=de-DE
but it should not work for
http://localhost:8083/hello/FooBar/en-GB
Optional parameters should only be allowed in a query parameter string and not in the path.
Any idea how to achieve this with Suave?