aboutsummaryrefslogtreecommitdiffstats
path: root/doc/src/manual/cowboy_router.ezdoc
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2014-07-06 13:10:35 +0200
committerLoïc Hoguin <[email protected]>2014-07-06 13:10:35 +0200
commit078d686a0ac0aed212db97d73bd1e4a9387a4956 (patch)
tree6bbc6111fdbdfedd3bb351bf3b01c63fac0d7143 /doc/src/manual/cowboy_router.ezdoc
parent1a71a733c37df70c15ebfd28157b10915cd738d1 (diff)
downloadcowboy-078d686a0ac0aed212db97d73bd1e4a9387a4956.tar.gz
cowboy-078d686a0ac0aed212db97d73bd1e4a9387a4956.tar.bz2
cowboy-078d686a0ac0aed212db97d73bd1e4a9387a4956.zip
Provide installable man pages
make docs: generate Markdown and man pages in doc/ make install-docs: install man pages to be usable directly Docs are generated from the ezdoc files in doc/src/.
Diffstat (limited to 'doc/src/manual/cowboy_router.ezdoc')
-rw-r--r--doc/src/manual/cowboy_router.ezdoc70
1 files changed, 70 insertions, 0 deletions
diff --git a/doc/src/manual/cowboy_router.ezdoc b/doc/src/manual/cowboy_router.ezdoc
new file mode 100644
index 0000000..f76acf6
--- /dev/null
+++ b/doc/src/manual/cowboy_router.ezdoc
@@ -0,0 +1,70 @@
+::: 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.
+
+: 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}]
+
+Types:
+
+* Host = Path = '_' | iodata()
+* Paths = [{Path, Handler, Opts} | {Path, constraints(), Handler, Opts}]
+* 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.