Debian Codegraph @

examples/eventsource/src/eventsource_app.erl

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