mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 11:15:35 -05:00
doc: update readme
This commit is contained in:
parent
6e54ee69b5
commit
80a4dc3c50
1 changed files with 7 additions and 4 deletions
11
README.md
11
README.md
|
|
@ -1,7 +1,8 @@
|
||||||
|
|
||||||
# Tiny_httpd [](https://travis-ci.org/c-cube/tiny_httpd) [](https://github.com/c-cube/tiny_httpd/actions)
|
# Tiny_httpd [](https://travis-ci.org/c-cube/tiny_httpd) [](https://github.com/c-cube/tiny_httpd/actions)
|
||||||
|
|
||||||
Minimal HTTP server using good old threads and `Scanf` for routing.
|
Minimal HTTP server using good old threads, with stream abstractions,
|
||||||
|
simple routing, URL encoding/decoding, and optional compression with camlzip.
|
||||||
|
|
||||||
Free from all forms of `ppx`, async monads, etc.
|
Free from all forms of `ppx`, async monads, etc.
|
||||||
|
|
||||||
|
|
@ -17,10 +18,12 @@ module S = Tiny_httpd
|
||||||
let () =
|
let () =
|
||||||
let server = S.create () in
|
let server = S.create () in
|
||||||
(* say hello *)
|
(* say hello *)
|
||||||
S.add_path_handler ~meth:`GET server
|
S.add_route_handler ~meth:`GET server
|
||||||
"/hello/%s@/" (fun name _req -> S.Response.make_ok ("hello " ^name ^"!\n"));
|
S.Route.(exact "hello" @/ string @/ return)
|
||||||
|
(fun name _req -> S.Response.make_ok ("hello " ^name ^"!\n"));
|
||||||
(* echo request *)
|
(* echo request *)
|
||||||
S.add_path_handler server
|
S.add_route_handler server
|
||||||
|
S.Route.(exact "echo" @/ return)
|
||||||
"/echo" (fun req -> S.Response.make_ok (Format.asprintf "echo:@ %a@." S.Request.pp req));
|
"/echo" (fun req -> S.Response.make_ok (Format.asprintf "echo:@ %a@." S.Request.pp req));
|
||||||
Printf.printf "listening on http://%s:%d\n%!" (S.addr server) (S.port server);
|
Printf.printf "listening on http://%s:%d\n%!" (S.addr server) (S.port server);
|
||||||
match S.run server with
|
match S.run server with
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue