Paste number 310213: | meh |
Pasted by: | aggelos |
When: | 8 years, 11 months ago |
Share: | Tweet this! | http://paste.lisp.org/+6ND1 |
Channel: | None |
Paste contents: |
let element_of_xml ?expected xml = let open Webdav in try let n = Xml.tag xml in begin match expected with | None -> Ok n | Some expected -> if String.compare n expected = 0 then begin Ok n end else begin Error (`Bad_request, sprintf "Expected <%s>, got <%s>" expected n) end end with Xml.Not_element _ -> Error (`Bad_request, sprintf "Expected an element, got %s" (Xml.to_string xml)) let webdav_result_map f = function | Webdav.Error _ as err -> err | Webdav.Ok x -> f x let propfind_request_of_prop prop = let open Webdav in List.fold_left (fun acc ch -> webdav_result_map (fun acc -> webdav_result_map (fun x -> Ok (x :: acc) ) (element_of_xml ch)) acc) (Ok []) (Xml.children prop)
This paste has no annotations.