mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-05 19:00:32 -05:00
doc: fix examples
This commit is contained in:
parent
697dc6c302
commit
70f1205880
2 changed files with 5 additions and 4 deletions
|
|
@ -20,11 +20,11 @@ let () =
|
|||
(* say hello *)
|
||||
S.add_route_handler ~meth:`GET server
|
||||
S.Route.(exact "hello" @/ string @/ return)
|
||||
(fun name _req -> S.Response.make_ok ("hello " ^name ^"!\n"));
|
||||
(fun name _req -> S.Response.make_string (Ok ("hello " ^name ^"!\n")));
|
||||
(* echo request *)
|
||||
S.add_route_handler server
|
||||
S.Route.(exact "echo" @/ return)
|
||||
(fun req -> S.Response.make_ok (Format.asprintf "echo:@ %a@." S.Request.pp req));
|
||||
(fun req -> S.Response.make_string (Ok (Format.asprintf "echo:@ %a@." S.Request.pp req)));
|
||||
Printf.printf "listening on http://%s:%d\n%!" (S.addr server) (S.port server);
|
||||
match S.run server with
|
||||
| Ok () -> ()
|
||||
|
|
|
|||
|
|
@ -18,11 +18,12 @@ let () =
|
|||
(* say hello *)
|
||||
S.add_route_handler ~meth:`GET server
|
||||
S.Route.(exact "hello" @/ string @/ return)
|
||||
(fun name _req -> S.Response.make_ok ("hello " ^name ^"!\n"));
|
||||
(fun name _req -> S.Response.make_string (Ok ("hello " ^name ^"!\n")));
|
||||
(* echo request *)
|
||||
S.add_route_handler server
|
||||
S.Route.(exact "echo" @/ return)
|
||||
(fun req -> S.Response.make_ok (Format.asprintf "echo:@ %a@." S.Request.pp req));
|
||||
(fun req -> S.Response.make_string
|
||||
(Ok (Format.asprintf "echo:@ %a@." S.Request.pp req)));
|
||||
S.add_route_handler ~meth:`PUT server
|
||||
S.Route.(exact "upload" @/ string_urlencoded @/ return)
|
||||
(fun path req ->
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue