From: Stefano Zacchiroli Date: Thu, 20 May 2004 14:33:20 +0000 (+0000) Subject: http basic authentication example X-Git-Tag: V_0_0_9~28 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=251eae74562c8baf816f169665b0e2ea9693daa3;p=helm.git http basic authentication example --- 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 +