X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2FDEVEL%2Focaml-http%2Fexamples%2Fbasic_auth.ml;fp=helm%2FDEVEL%2Focaml-http%2Fexamples%2Fbasic_auth.ml;h=f9d75a7c5e4e64ec37771de43ff4ca70f44c6eaa;hb=251eae74562c8baf816f169665b0e2ea9693daa3;hp=0000000000000000000000000000000000000000;hpb=77449a59416260cca5c239f43434cddc218c67ff;p=helm.git 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 +