Skip to content

Instantly share code, notes, and snippets.

@isaacabraham
Last active October 31, 2016 13:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacabraham/22fb2f27838f699457ec to your computer and use it in GitHub Desktop.
Save isaacabraham/22fb2f27838f699457ec to your computer and use it in GitHub Desktop.
F# Web API controller
type ExampleRequest =
{ Name : string
Age : int }
type ExampleController() =
inherit ApiController()
/// Maps to HTTP GET.
member __.Get(id : string) =
sprintf "Hello %s from F#!" id
/// Maps to HTTP POST.
member __.Post(request : ExampleRequest) =
async {
return match request.Age with
| 18 -> "You are 18!"
| _ -> "You are not 18!"
} |> Async.StartAsTask // can easily make asynchronous controller methods.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment