]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/ocaml-http/examples/basic_auth.ml
http basic authentication example
[helm.git] / helm / DEVEL / ocaml-http / examples / basic_auth.ml
1
2 let callback (req: Http_types.request) outchan =
3   match req#authorization with
4   | Some (`Basic (username, password))
5     when username = "foo" && password = "bar" ->
6       Http_daemon.respond ~code:200 ~body:"secret page!" outchan
7   | _ -> raise (Http_types.Unauthorized "my secret site")
8
9 let _ = Http_daemon.start' ~port:9999 callback
10