Tiny_httpd_core.Route
Routing
Basic type-safe routing of handlers based on URL paths. This is optional, it is possible to only define the root handler with something like Routes.
val int : (int -> 'a, 'a) comp
Matches an integer.
val string : (string -> 'a, 'a) comp
Matches a string not containing '/'
and binds it as is.
val string_urlencoded : (string -> 'a, 'a) comp
Matches a URL-encoded string, and decodes it.
val exact : string -> ('a, 'a) comp
exact "s"
matches "s"
and nothing else.
val return : ('a, 'a) t
Matches the empty path.
val rest_of_path : (string -> 'a, 'a) t
Matches a string, even containing '/'
. This will match the entirety of the remaining route.
val rest_of_path_urlencoded : (string -> 'a, 'a) t
Matches a string, even containing '/'
, an URL-decode it. This will match the entirety of the remaining route.
comp / route
matches "foo/bar/…"
iff comp
matches "foo"
, and route
matches "bar/…"
.
exact_path "foo/bar/..." r
is equivalent to exact "foo" @/ exact "bar" @/ ... @/ r
val pp : Stdlib.Format.formatter -> (_, _) t -> unit
Print the route.
val to_string : (_, _) t -> string
Print the route.
module Private_ : sig ... end