Debian Codegraph @

doc/src/manual/cowboy_router.compile.asciidoc

raw
1 = cowboy_router:compile(3)
2
3 == Name
4
5 cowboy_router:compile - Compile routes to the resources
6
7 == Description
8
9 [source,erlang]
10 ----
11 compile(cowboy_router:routes()) -> cowboy_router:dispatch_rules()
12 ----
13
14 Compile routes to the resources.
15
16 Takes a human readable list of routes and transforms it
17 into a form more efficient to process.
18
19 == Arguments
20
21 Routes::
22
23 Human readable list of routes.
24
25 == Return value
26
27 An opaque dispatch rules value is returned. This value
28 must be given to Cowboy as a middleware environment value.
29
30 == Changelog
31
32 * *1.0*: Function introduced.
33
34 == Examples
35
36 .Compile routes and start a listener
37 [source,erlang]
38 ----
39 Dispatch = cowboy_router:compile([
40 {'_', [
41 {"/", toppage_h, []},
42 {"/[...]", cowboy_static, {priv_dir, my_example_app, ""}}
43 ]}
44 ]),
45
46 {ok, _} = cowboy:start_clear(example, [{port, 8080}], #{
47 env => #{dispatch => Dispatch}
48 }).
49 ----
50
51 == See also
52
53 link:man:cowboy_router(3)[cowboy_router(3)]