Last active
August 29, 2015 14:06
-
-
Save danielrbradley/42cc5bdb06b59e214acb to your computer and use it in GitHub Desktop.
Optional query parameters in WebAPI with F#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Web | |
open System.Web.Http | |
[<AllowNullLiteral>] | |
type QueryModel() = | |
member val Top = 50 with get, set | |
member val Skip = 0 with get, set | |
[<RoutePrefix("api/test")>] | |
type TestController() = | |
inherit ApiController() | |
[<HttpGet; Route("")>] | |
member controller.Get ([<FromUri>]model : QueryModel) = | |
let model = if model = null then QueryModel() else model | |
async { | |
return seq { model.Skip .. (model.Top + model.Skip) } | |
} | |
|> Async.StartAsTask |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment