From 251eae74562c8baf816f169665b0e2ea9693daa3 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Thu, 20 May 2004 14:33:20 +0000 Subject: [PATCH] http basic authentication example --- helm/DEVEL/ocaml-http/examples/basic_auth.ml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 helm/DEVEL/ocaml-http/examples/basic_auth.ml diff --git a/helm/DEVEL/ocaml-http/examples/basic_auth.ml b/helm/DEVEL/ocaml-http/examples/basic_auth.ml new file mode 100644 index 000000000..f9d75a7c5 --- /dev/null +++ b/helm/DEVEL/ocaml-http/examples/basic_auth.ml @@ -0,0 +1,10 @@ + +let callback (req: Http_types.request) outchan = + match req#authorization with + | Some (`Basic (username, password)) + when username = "foo" && password = "bar" -> + Http_daemon.respond ~code:200 ~body:"secret page!" outchan + | _ -> raise (Http_types.Unauthorized "my secret site") + +let _ = Http_daemon.start' ~port:9999 callback + -- 2.39.2