diff --git a/lib/webmachine.ml b/lib/webmachine.ml index e57bd47..824d850 100644 --- a/lib/webmachine.ml +++ b/lib/webmachine.ml @@ -917,17 +917,18 @@ module Make(IO:IO)(Clock:CLOCK) = struct let dispatch table = let table = - List.map (fun (p, t, mk_resource) -> - (p, t, fun path_info dispatch_path ~body ~request -> - let resource = mk_resource () in - to_handler ?dispatch_path ~path_info ~resource ~body ~request ())) - table + Dispatch.create + (List.map (fun (p, t, mk_resource) -> + (p, t, fun path_info dispatch_path ~body ~request -> + let resource = mk_resource () in + to_handler ?dispatch_path ~path_info ~resource ~body ~request ())) + table) in fun ~body ~request -> let path = Uri.path (Cohttp.Request.uri request) in match Dispatch.dispatch table path with - | Result.Error _ -> return None - | Result.Ok handler -> handler ~body ~request >>= fun x -> return (Some x) + | None -> return None + | Some handler -> handler ~body ~request >>= fun x -> return (Some x) let dispatch' table = dispatch (List.map (fun (m, r) -> diff --git a/webmachine.opam b/webmachine.opam index 1164682..c2c61c6 100644 --- a/webmachine.opam +++ b/webmachine.opam @@ -14,7 +14,7 @@ depends: [ "ocaml" {>= "4.03.0"} "ptime" {>= "0.8.0"} "cohttp" {>= "1.0.0"} - "dispatch" {>= "0.3.0" & < "0.5.0"} + "dispatch" {>= "0.5.0"} "dune" {>= "1.0"} "ounit" {with-test & >= "1.0.2"} "re" {>= "1.7.2"}