let doc = ClientHTTP.get (sprintf "%sresolve?uri=%s" (getter_url ()) uri) in
let res = ref Unknown in
Pxp_ev_parser.process_entity PxpHelmConf.pxp_config (`Entry_content [])
- (Pxp_ev_parser.create_entity_manager ~is_document:true PxpHelmConf.pxp_config
- (Pxp_yacc.from_string doc))
+ (Pxp_ev_parser.create_entity_manager ~is_document:true
+ PxpHelmConf.pxp_config (Pxp_yacc.from_string doc))
(function
| Pxp_types.E_start_tag ("url",["value",url],_,_) -> res := Resolved url
- | Pxp_types.E_start_tag ("unresolved",[],_,_) ->
+ | Pxp_types.E_start_tag ("unresolvable",[],_,_) ->
res := Exception (Unresolvable_URI uri)
+ | Pxp_types.E_start_tag ("not_found",[],_,_) ->
+ res := Exception (Key_not_found uri)
| Pxp_types.E_start_tag _ -> res := Exception UnexpectedGetterOutput
| _ -> ());
match !res with
let register_remote ~uri ~url =
ClientHTTP.send (sprintf "%sregister?uri=%s&url=%s" (getter_url ()) uri url)
-let register_remote ~uri ~url =
- ClientHTTP.send (sprintf "%sregister?uri=%s&url=%s" (getter_url ()) uri url)
+let unregister_remote uri =
+ ClientHTTP.send (sprintf "%sunregister?uri=%s" (getter_url ()) uri)
let update_remote logger () =
let answer = ClientHTTP.get (getter_url () ^ "update") in
if remote () then
resolve_remote uri
else
- try
- (map_of_uri uri)#resolve uri
- with Http_getter_map.Key_not_found _ -> raise (Unresolvable_URI uri)
+ (map_of_uri uri)#resolve uri
- (* Warning: this fail if uri is already registered *)
let register ~uri ~url =
if remote () then
register_remote ~uri ~url
else
(map_of_uri uri)#add uri url
+let unregister uri =
+ if remote () then
+ unregister_remote uri
+ else
+ (map_of_uri uri)#remove uri
+
let update ?(logger = fun _ -> ()) () =
if remote () then
update_remote logger ()
(** {2 Getter Web Service interface as API *)
val help: unit -> string
+
+ (** @raise Http_getter_types.Unresolvable_URI _
+ * @raise Http_getter_types.Key_not_found _ *)
val resolve: string -> string (* uri -> url *)
+
+ (** @raise Http_getter_types.Key_already_in _ *)
val register: uri:string -> url:string -> unit
+
+ (** @raise Http_getter_types.Key_not_found _ *)
+val unregister: string -> unit
+
val update: ?logger:logger_callback -> unit -> unit
val getxml : ?format:encoding -> ?patch_dtd:bool -> string -> string
val getxslt : ?patch_dtd:bool -> string -> string