package yurt

  1. Overview
  2. Docs
exception Invalid_route_type

The `Route module helps with building routes

type route = [
  1. | `String of string
  2. | `Int of string
  3. | `Float of string
  4. | `Path of string
  5. | `Match of string * string
  6. | `Route of route list
]

The route type allows for URL routes to be built using strong types

type params = (string, route) Stdlib.Hashtbl.t

The type that contains parsed URL parameters

val route_cache : (route, Str.regexp) Stdlib.Hashtbl.t

The route cache allows the route -> regexp process to be memoized

val concat_filenames : string list -> string
val slash_regexp : Str.regexp
val routevar_regexp : Str.regexp
val to_string : route -> string

Convert a route to string

val to_regexp : route -> Str.regexp

Convert a route to regexp

val of_string : string -> [> `Route of [> `Float of string | `Int of string | `Match of string * string | `Path of string | `String of string ] list ]

"/user/<name:int>" -> `Path "user", `Int "name"

val variables : [< `Float of 'b | `Int of 'c | `Match of 'd | `Path of 'e | `Route of 'a list | `String of 'f Route ] as 'a -> 'a list

Returns a list of variables found in a route

val matches : route -> string -> bool

Check to see if a string matches the route's regexp

val params : [< `Float of 'b | `Int of 'b | `Match of 'b * 'c | `Path of 'd | `Route of 'a list | `String of 'b Route ] as 'a -> string -> ('b, [> `Float of string | `Int of string | `String of string ]) Stdlib.Hashtbl.t

Get a parameters after a successful route match

val int : ('a, [> `Float of string | `Int of string | `Match of 'b * string | `String of string ]) Stdlib.Hashtbl.t -> 'a -> int

Get a single parameter as int by name

val float : ('a, [> `Float of string | `Int of string | `Match of 'b * string | `String of string ]) Stdlib.Hashtbl.t -> 'a -> float

Get a single parameter as float by name

val string : ('a, [> `Float of string | `Int of string | `Match of 'b * string | `String of string ]) Stdlib.Hashtbl.t -> 'a -> string

Get a single parameter as string by name

val json_of_route : [< `Float of string | `Int of string | `Match of 'b * string | `Path of string | `Route of 'a list | `String of string ] as 'a -> Ezjsonm.value
val to_json : ('a, [< `Float of string | `Int of string | `Match of 'c * string | `Path of string | `Route of 'b list | `String of string ] as 'b) Stdlib.Hashtbl.t -> [> `O of ('a * Ezjsonm.value) list ]
OCaml

Innovation. Community. Security.