2014-07-06 13:10:35 +02:00
|
|
|
::: cowboy_router
|
|
|
|
|
|
|
|
The `cowboy_router` middleware maps the requested host and
|
|
|
|
path to the handler to be used for processing the request.
|
|
|
|
It uses the dispatch rules compiled from the routes given
|
|
|
|
to the `compile/1` function for this purpose. It adds the
|
|
|
|
handler name and options to the environment as the values
|
|
|
|
`handler` and `handler_opts` respectively.
|
|
|
|
|
|
|
|
Environment input:
|
|
|
|
|
|
|
|
* dispatch = dispatch_rules()
|
|
|
|
|
|
|
|
Environment output:
|
|
|
|
|
|
|
|
* handler = module()
|
|
|
|
* handler_opts = any()
|
|
|
|
|
|
|
|
:: Types
|
|
|
|
|
|
|
|
: bindings() = [{atom(), binary()}]
|
|
|
|
|
|
|
|
List of bindings found during routing.
|
|
|
|
|
|
|
|
: dispatch_rules() - opaque to the user
|
|
|
|
|
|
|
|
Rules for dispatching request used by Cowboy.
|
|
|
|
|
2014-09-23 21:36:52 +03:00
|
|
|
: routes() = [{Host, Paths} | {Host, cowboy:fields(), Paths}]
|
2014-07-06 13:10:35 +02:00
|
|
|
|
|
|
|
Types:
|
|
|
|
|
|
|
|
* Host = Path = '_' | iodata()
|
2014-09-23 21:36:52 +03:00
|
|
|
* Paths = [{Path, Handler, Opts} | {Path, cowboy:fields(), Handler, Opts}]
|
2014-07-06 13:10:35 +02:00
|
|
|
* Handler = module()
|
|
|
|
* Opts = any()
|
|
|
|
|
|
|
|
Human readable list of routes mapping hosts and paths to handlers.
|
|
|
|
|
|
|
|
The syntax for routes is defined in the user guide.
|
|
|
|
|
|
|
|
: tokens() = [binary()]
|
|
|
|
|
|
|
|
List of host_info and path_info tokens found during routing.
|
|
|
|
|
|
|
|
:: Exports
|
|
|
|
|
|
|
|
: compile(Routes) -> Dispatch
|
|
|
|
|
|
|
|
Types:
|
|
|
|
|
|
|
|
* Routes = routes()
|
|
|
|
* Dispatch = dispatch_rules()
|
|
|
|
|
|
|
|
Compile the routes for use by Cowboy.
|