Skip to content

Instantly share code, notes, and snippets.

@eulerfx
Created March 26, 2014 00:36
Show Gist options
  • Select an option

  • Save eulerfx/9774617 to your computer and use it in GitHub Desktop.

Select an option

Save eulerfx/9774617 to your computer and use it in GitHub Desktop.
F# http service with HyperF
#load "HyperF.fsx"
open HyperF
open Route
let service =
[
Get("/resource/:id") => fun (req,ri) -> "hello world!" |> HttpRes.plainText
Put("/resource/:id") => fun (req,ri) -> async {
do! Async.Sleep(1000)
return! HttpRes.plainText "done!" }
] |> Route.toService
let filteredService =
Filter.identity
|> Filter.andThen Filter.printBeforeAfterTag
|> Filter.toService service
Http.host "http://+:8081/" filteredService |> Async.RunSynchronously
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment