Last active
October 26, 2016 19:22
-
-
Save jlongster/7cb0b4d2b6ce4d634018886a926e9dc7 to your computer and use it in GitHub Desktop.
This file contains 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
let router = | |
Router.create () |> | |
Router.post | |
"/" | |
( | |
fun req body => | |
Cohttp_lwt_body.to_string body >>= ( | |
fun body => { | |
let str = | |
switch (Uri.get_query_param (req |> Request.uri) "foo") { | |
| None => "" | |
| Some x => x | |
}; | |
let json = Yojson.Basic.from_string str; | |
let synced_from = json |> Util.member "synced_from" |> Util.to_string; | |
let response = Yojson.Basic.to_string ( | |
`Assoc [ | |
("id", `String (Uuidm.to_string (Uuidm.v `V4))), | |
("devices", `String synced_from) | |
] | |
); | |
Server.respond_string status::`OK body::response () | |
} | |
) | |
) |> | |
Router.get "/foo" (fun req body => Server.respond_string status::`OK body::"/foo" ()) |> | |
Router.get "/bar" (fun req body => Server.respond_string status::`OK body::"/bar" ()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment