Skip to content

Commit

Permalink
Merge pull request #108 from hannesm/dispatch.0.5.0
Browse files Browse the repository at this point in the history
adapt to dispatch 0.5.0 API changes
  • Loading branch information
seliopou committed Sep 22, 2020
2 parents 9ef128f + f951901 commit fc0eb63
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions lib/webmachine.ml
Expand Up @@ -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) ->
Expand Down
2 changes: 1 addition & 1 deletion webmachine.opam
Expand Up @@ -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"}
Expand Down

0 comments on commit fc0eb63

Please sign in to comment.