+open Http_types
+
+(* the easy way: specify authentication requirements within a daemon_spec *)
+let spec =
+ { Http_daemon.default_spec with
+ (* requires basic authentication, username "foo", password "bar" *)
+ auth = Some ("my realm", `Basic ("foo", "bar"));
+ callback = (fun _ outchan -> Http_daemon.respond ~body:"secret" outchan);
+ port = 9999;
+ }
+
+(*
+(* the hard^Wother way: manual handling of authorization *)
+let callback req outchan =