0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 04:30:25 +00:00

Make routing constraints use the fields format

This makes routing more in line with the rest of Cowboy and
allows us to use cowboy_constraints directly.
This commit is contained in:
Loïc Hoguin 2014-09-23 21:36:52 +03:00
parent f1c3b6d76f
commit 25259671f5
3 changed files with 36 additions and 70 deletions

View file

@ -22,31 +22,16 @@ Environment output:
List of bindings found during routing.
: constraints() = [IntConstraint | FunConstraint]
Types:
* IntConstraint = {atom(), int}
* FunConstraint = {atom(), function, Fun}
* Fun = fun((binary()) -> true | {true, any()} | false)
List of constraints to apply to the bindings.
The int constraint will convert the binding to an integer.
The fun constraint allows writing custom code for checking
the bindings. Returning a new value from that fun allows
replacing the current binding with a new value.
: dispatch_rules() - opaque to the user
Rules for dispatching request used by Cowboy.
: routes() = [{Host, Paths} | {Host, constraints(), Paths}]
: routes() = [{Host, Paths} | {Host, cowboy:fields(), Paths}]
Types:
* Host = Path = '_' | iodata()
* Paths = [{Path, Handler, Opts} | {Path, constraints(), Handler, Opts}]
* Paths = [{Path, Handler, Opts} | {Path, cowboy:fields(), Handler, Opts}]
* Handler = module()
* Opts = any()