Skip to content

Instantly share code, notes, and snippets.

@danielrbradley
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielrbradley/42cc5bdb06b59e214acb to your computer and use it in GitHub Desktop.
Save danielrbradley/42cc5bdb06b59e214acb to your computer and use it in GitHub Desktop.
Optional query parameters in WebAPI with F#
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