From 353cee7a5da747b49e7c6ad647f269b11ac4a876 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 29 Mar 2022 22:54:37 -0400 Subject: [PATCH] echo: make `quit` into a button, to perform the POST action properly --- examples/echo.ml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/examples/echo.ml b/examples/echo.ml index c36f1566..99704b1f 100644 --- a/examples/echo.ml +++ b/examples/echo.ml @@ -178,8 +178,19 @@ let () = 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 "/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"]]; - li[][pre[][a[A.href "/protected"][txt "/protected"]; txt" (GET) to see a protected page (user:foobar)"]]; + li[][ + pre[A.style "display: inline"][ + a[A.href "/quit"][txt "/quit"]; txt" (POST) to stop server" + ]; + form[A.style "display: inline"; + A.action "/quit"; A.method_ "POST"; + ][ + button + [A.type_ "submit"] + [txt"quit"] + ]; + ]; + li[][pre[][a[A.href "/protected"][txt "/protected"]; txt" (GET) to see a protected page (login: user, password: foobar)"]]; li[][pre[][a[A.href "/logout"][txt "/logout"]; txt" (POST) to log out"]]; ] ]