From a1b52494a54ede247a5eb0448a94aeb76d61f74e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 22 Dec 2016 12:53:21 +0100 Subject: Update the cowboy_router manual --- doc/src/manual/cowboy_router.compile.asciidoc | 53 +++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 doc/src/manual/cowboy_router.compile.asciidoc (limited to 'doc/src/manual/cowboy_router.compile.asciidoc') diff --git a/doc/src/manual/cowboy_router.compile.asciidoc b/doc/src/manual/cowboy_router.compile.asciidoc new file mode 100644 index 0000000..ab4eddc --- /dev/null +++ b/doc/src/manual/cowboy_router.compile.asciidoc @@ -0,0 +1,53 @@ += cowboy_router:compile(3) + +== Name + +cowboy_router:compile - Compile routes to the resources + +== Description + +[source,erlang] +---- +compile(cowboy_router:routes()) -> cowboy_router:dispatch_rules() +---- + +Compile routes to the resources. + +Takes a human readable list of routes and transforms it +into a form more efficient to process. + +== Arguments + +Routes:: + +Human readable list of routes. + +== Return value + +An opaque dispatch rules value is returned. This value +must be given to Cowboy as a middleware environment value. + +== Changelog + +* *1.0*: Function introduced. + +== Examples + +.Compile routes and start a listener +[source,erlang] +---- +Dispatch = cowboy_router:compile([ + {'_', [ + {"/", toppage_h, []}, + {"/[...], cowboy_static, {priv_dir, my_example_app, ""}} + ]} +]), + +{ok, _} = cowboy:start_clear(example, 100, [{port, 8080}], #{ + env => #{dispatch => Dispatch} +}). +---- + +== See also + +link:man:cowboy_router(3)[cowboy_router(3)] -- cgit v1.2.3