The type tag for a path component.
`Lit indiciates that the component should match exactly, while
`Var indicates that the component can be anything and should be associated with the variable name provided in the tuple.
The type of match for the route.
`Prefix indicates that the route does not need to match the entirety of the path, while
`Exact indicates an exact match.
The type of a route. The first tuple element specifies the matching rules for the path components, with the tag indicating the type of match. The interpretation of the corresponding string depends on the tag provided: for
(`Lit, lit), the path component must match the string
lit exactly; for
(`Var, name), the path component can be anything and will be associated with
name in the event of a successful match.
The second component of the tuple indicates the type of match that this route support, which can be either a prefix match (indicated by the
`Prefix variant), or an exact match (indicated by the
The third and final component is the handler function. On a successful route match, the matching information will be passed to the handler to produce a value of tyoe
'a that will be returned.
val dispatch_exn : 'a route list -> string -> 'a
dispatch routes path iterates through
routes and selects the first one that matches
path. It then applies the route handler to any component mappings and trailing path components (in the case of a prefix match) and returns the result. If none of the
path, it will return an
dispatch_exn routes path behaves just like
dispatch routes path except will raise an exception using
failwith in the case of no matches.
to_dsl route_spec is a string in the routing DSL that will beahve in the exact same way as
A good way to become comfortable with the DSL is to load up this library in the REPL of your choice and translate route patterns to the DSL using the function
module DSL : sig ... end
A module that implements the dispatch operations for a DLS represented as a string literal. A more familiar interface for the Web world.