Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* test.ml *)
- open Lwt
- open Cohttp
- open Cohttp_lwt_unix
- open Core.Std
- let server =
- let callback _conn req body =
- let uri = req |> Request.uri |> Uri.to_string in
- let meth = req |> Request.meth |> Code.string_of_method in
- let headers = req |> Request.headers |> Header.to_string in
- body |> Cohttp_lwt_body.to_string >|= (fun body ->
- (Printf.sprintf "Uri: %s\nMethod: %s\nHeaders\nHeaders: %s\nBody: %s"
- uri meth headers body))
- >>= (fun body -> Server.respond_string ~status:`OK ~body ())
- in
- Server.create ~mode:(`TCP (`Port 8000)) (Server.make ~callback ())
- (*
- let () = ignore (Lwt_main.run server)
- *)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement