]> matita.cs.unibo.it Git - helm.git/commitdiff
http basic authentication example
authorStefano Zacchiroli <zack@upsilon.cc>
Thu, 20 May 2004 14:33:20 +0000 (14:33 +0000)
committerStefano Zacchiroli <zack@upsilon.cc>
Thu, 20 May 2004 14:33:20 +0000 (14:33 +0000)
helm/DEVEL/ocaml-http/examples/basic_auth.ml [new file with mode: 0644]

diff --git a/helm/DEVEL/ocaml-http/examples/basic_auth.ml b/helm/DEVEL/ocaml-http/examples/basic_auth.ml
new file mode 100644 (file)
index 0000000..f9d75a7
--- /dev/null
@@ -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
+