To process the request parameters, I would simply use the request function, which gives you all the information about the original HTTP request. You can use this to check query parameters:
let handleHello name = request (fun r -> let lang = match r.queryParam "lang" with | Choice1Of2 lang -> lang | _ -> "en-GB" OK (sprintf "Hello from %s in language %s" name lang)) let app = choose [ GET >=> choose [ path "/hello" >=> OK "Hello World!" pathScan "/hello/%s" handleHello ] NOT_FOUND "Not found" ]
Tomas petricek
source share