package yurt

  1. Overview
  2. Docs

Module Yurt_routeSource

Sourceexception Invalid_route_type

The `Route module helps with building routes

Sourcetype 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

Sourcetype params = (string, route) Hashtbl.t

The type that contains parsed URL parameters

Sourceval route_cache : (route, Str.regexp) Hashtbl.t

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

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

Convert a route to string

Sourceval to_regexp : route -> Str.regexp

Convert a route to regexp

Sourceval 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"

Sourceval 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

Sourceval matches : route -> string -> bool

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

Sourceval 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 ]) Hashtbl.t

Get a parameters after a successful route match

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

Get a single parameter as int by name

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

Get a single parameter as float by name

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

Get a single parameter as string by name

Sourceval 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
Sourceval 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) Hashtbl.t -> [> `O of ('a * Ezjsonm.value) list ]
OCaml

Innovation. Community. Security.