Debian Codegraph @

examples/websocket/src/websocket_app.erl

raw
1 %% Feel free to use, reuse and abuse the code in this file.
2
3 %% @private
4 -module(websocket_app).
5 -behaviour(application).
6
7 %% API.
8 -export([start/2]).
9 -export([stop/1]).
10
11 %% API.
12 start(_Type, _Args) ->
13 Dispatch = cowboy_router:compile([
14 {'_', [
15 {"/", cowboy_static, {priv_file, websocket, "index.html"}},
16 {"/websocket", ws_h, []},
17 {"/static/[...]", cowboy_static, {priv_dir, websocket, "static"}}
18 ]}
19 ]),
20 {ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
21 env => #{dispatch => Dispatch}
22 }),
23 websocket_sup:start_link().
24
25 stop(_State) ->
26 ok = cowboy:stop_listener(http).