Helm_registry.load_from configuration_file
;;
-let open_db ~host ~database ~port ~password ~user =
+let open_db ?host ?database ?port ?password ?user =
try
- M.quick_connect ~host ~database ~port ~password ~user
+ M.quick_connect ?host ?database ?port ?password ?user
with
M.Error e as exc ->
prerr_endline e ;
let return_400 body ch = Http_daemon.respond_error ~code:400 ~body ch
let return_html_error s = return_html ("<html><body>" ^ s ^ "</body></html>")
-let host = Helm_registry.get "rdfly.mysql_connection.host";;
-let database = Helm_registry.get "rdfly.mysql_connection.database";;
-let port = Helm_registry.get_int "rdfly.mysql_connection.port";;
-let password = Helm_registry.get "rdfly.mysql_connection.password";;
-let user = Helm_registry.get "rdfly.mysql_connection.user";;
+let get_option key =
+ try
+ Some (Helm_registry.get key)
+ with Helm_registry.Key_not_found _ -> None
+
+let get_int_option key =
+ try
+ Some (Helm_registry.get_int key)
+ with Helm_registry.Key_not_found _ -> None
+
+let host = get_option "rdfly.mysql_connection.host";;
+let database = get_option "rdfly.mysql_connection.database";;
+let port = get_int_option "rdfly.mysql_connection.port";;
+let password = get_option "rdfly.mysql_connection.password";;
+let user = get_option "rdfly.mysql_connection.user";;
let daemonport = Helm_registry.get_int "rdfly.port";;
let callback (req: Http_types.request) ch =
| "/get" ->
let obj = req#param "object"
and kind = req#param "kind" in
- let db = open_db ~host ~database ~port ~password ~user () in
+ let db = open_db ?host ?database ?port ?password ?user () in
begin
match kind with
"forward" -> return_xml (forward_metadata db obj) ch