feat(echo): add a /quit POST endpoint to terminate

This commit is contained in:
Simon Cruanes 2022-01-01 23:10:58 -05:00
parent 55c9bdd2e0
commit 0b3af5cd6e
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -126,6 +126,10 @@ let () =
~dir_behavior:Tiny_httpd_dir.Index_or_lists ()) ~dir_behavior:Tiny_httpd_dir.Index_or_lists ())
~vfs:Vfs.vfs ~prefix:"vfs"; ~vfs:Vfs.vfs ~prefix:"vfs";
(* quit *)
S.add_route_handler server ~meth:`POST S.Route.(exact "quit" @/ return)
(fun _ -> S.stop server; S.Response.make_string @@ Ok "stopping…");
(* main page *) (* main page *)
S.add_route_handler server S.Route.(return) S.add_route_handler server S.Route.(return)
(fun _req -> (fun _req ->
@ -142,6 +146,7 @@ let () =
li[][pre[][txt "/zcat/:path (GET) to download a file (deflate transfer-encoding)"]]; li[][pre[][txt "/zcat/:path (GET) to download a file (deflate transfer-encoding)"]];
li[][pre[][a[A.href "/stats/"][txt"/stats/"]; txt" (GET) to access statistics"]]; li[][pre[][a[A.href "/stats/"][txt"/stats/"]; txt" (GET) to access statistics"]];
li[][pre[][a[A.href "/vfs/"][txt"/vfs"]; txt" (GET) to access a VFS embedded in the binary"]]; li[][pre[][a[A.href "/vfs/"][txt"/vfs"]; txt" (GET) to access a VFS embedded in the binary"]];
li[][pre[][a[A.href "/quit"][txt "/quit"]; txt" (POST) to quit"]];
] ]
] ]
] in ] in