bindings() :: #{atom() => any()}
cowboy_router - Router middleware
The cowboy_router
middleware maps the requested host and
path to the handler to be used for processing the request.
The router takes the dispatch
rules as input from the
middleware environment. Dispatch rules are generated by
calling the
cowboy_router:compile(3)
function.
When a route matches, the router sets the handler
and
handler_opts
middleware environment values containing
the handler module and initial state, respectively.
The router will stop execution when no route matches. It will send a 400 response if no host was found, and a 404 response otherwise.
cowboy_router:compile(3) - Compile routes to the resources
bindings() :: #{atom() => any()}
Bindings found during routing.
Opaque type containing the compiled routes.
routes() = [ {Host, PathList} | {Host, Fields, PathList} ] PathList :: [ {Path, Handler, InitialState} | {Path, Fields, Handler, InitialState} ] Host :: '_' | iodata() Path :: '_' | iodata() Fields :: cowboy:fields() Handler :: module() InitialState :: any()
Human readable list of routes to handlers.
Cowboy uses this list to map hosts and paths, optionally augmented with constraints applied to the bindings, to handler modules.
The syntax for routes is currently defined in the user guide.
tokens() :: [binary()]
List of host_info
and path_info
tokens that were found
using the ...
syntax.