Madge
module Request : sig ... end
module Route : sig ... end
type ('a, 'w, 'r) route = ('a, 'w, 'r) Route.t
The heart of Madge, where we link routes and requests.
val uri : ('a, Uri.t, 'r) Route.t -> 'a
Easiest way to use a route: transform it into a URI. The 'a
parameter corresponds to the function of that route, with Uri.t
as return type. For instance, if r
has type (int -> float -> 'w, 'w, 'r) route
, then uri r
will have type int -> float -> Uri.t
.
val with_request :
('a, 'w, 'r) Route.t ->
((module Madge__.Serialisation.JSONABLE with type t = 'r) -> Request.t -> 'w) ->
'a
Generic way to use a route. Given a route and a continuation, create a request from the route, pass that request to the continuation, and return the resulting value. For instance, uri
is simply process route (fun
(module _) {uri; _} -> uri)
.
Given a route, a controller, and a request, check whether the route matches the request. If so, construct a thunk that calls the controller with the correct arguments. Otherwise, return None
.
val apply :
('a, 'w, 'r) Route.t ->
(unit -> 'a) ->
Request.t ->
((module Madge__.Serialisation.JSONABLE with type t = 'r) ->
(unit -> 'w) ->
'z) ->
(unit -> 'z) option
Given a route, a controller, a request, and a continuation, check whether the route matches. If so, construct a thunk that calls the controller with the correct arguments and passes it to the continuation. Otherwise, return None
. For instance, match_'
is simply match_ route controller request
(fun _ f -> f ())
.
module type STRINGABLE = sig ... end
module type JSONABLE = sig ... end
module SString : sig ... end
module SStatusCode : sig ... end
module JString : sig ... end
module JUri : sig ... end
module JUnit : sig ... end
module JVoid : sig ... end
module JBool : sig ... end
module JInt : sig ... end
module JFloat : sig ... end
module type TYPEABLE = sig ... end