| 1 |
|
-module(shurbej_web_app). |
| 2 |
|
-behaviour(application). |
| 3 |
|
|
| 4 |
|
-export([start/2, stop/1]). |
| 5 |
|
|
| 6 |
|
start(_StartType, _StartArgs) -> |
| 7 |
1 |
Dispatch = cowboy_router:compile([ |
| 8 |
|
{'_', shurbej_http:routes()} |
| 9 |
|
]), |
| 10 |
1 |
Port = application:get_env(shurbej, http_port, 8080), |
| 11 |
1 |
{ok, _} = cowboy:start_clear( |
| 12 |
|
shurbej_http, |
| 13 |
|
[{port, Port}], |
| 14 |
|
#{env => #{dispatch => Dispatch}} |
| 15 |
|
), |
| 16 |
1 |
logger:notice("shurbej listening on port ~p", [Port]), |
| 17 |
1 |
shurbej_web_sup:start_link(). |
| 18 |
|
|
| 19 |
|
stop(_State) -> |
| 20 |
:-( |
cowboy:stop_listener(shurbej_http), |
| 21 |
:-( |
ok. |