File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 11
22# Tiny_httpd [ ![ build status] ( https://travis-ci.org/c-cube/tiny_httpd.svg?branch=master )] ( https://travis-ci.org/c-cube/tiny_httpd ) [ ![ build] ( https://github.com/c-cube/tiny_httpd/workflows/build/badge.svg )] ( https://github.com/c-cube/tiny_httpd/actions )
33
4- Minimal HTTP server using good old threads and ` Scanf ` for routing.
4+ Minimal HTTP server using good old threads, with stream abstractions,
5+ simple routing, URL encoding/decoding, and optional compression with camlzip.
56
67Free from all forms of ` ppx ` , async monads, etc.
78
@@ -17,10 +18,12 @@ module S = Tiny_httpd
1718let () =
1819 let server = S.create () in
1920 (* say hello *)
20- S.add_path_handler ~meth:`GET server
21- "/hello/%s@/" (fun name _req -> S.Response.make_ok ("hello " ^name ^"!\n"));
21+ S.add_route_handler ~meth:`GET server
22+ S.Route.(exact "hello" @/ string @/ return)
23+ (fun name _req -> S.Response.make_ok ("hello " ^name ^"!\n"));
2224 (* echo request *)
23- S.add_path_handler server
25+ S.add_route_handler server
26+ S.Route.(exact "echo" @/ return)
2427 "/echo" (fun req -> S.Response.make_ok (Format.asprintf "echo:@ %a@." S.Request.pp req));
2528 Printf.printf "listening on http://%s:%d\n%!" (S.addr server) (S.port server);
2629 match S.run server with
You can’t perform that action at this time.
0 commit comments