_site/cover/pgec_app.COVER.html

1 %% Copyright (c) 2022 Peter Morgan <peter.james.morgan@gmail.com>
2 %%
3 %% Licensed under the Apache License, Version 2.0 (the "License");
4 %% you may not use this file except in compliance with the License.
5 %% You may obtain a copy of the License at
6 %%
7 %% http://www.apache.org/licenses/LICENSE-2.0
8 %%
9 %% Unless required by applicable law or agreed to in writing, software
10 %% distributed under the License is distributed on an "AS IS" BASIS,
11 %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 %% See the License for the specific language governing permissions and
13 %% limitations under the License.
14
15
16 -module(pgec_app).
17
18
19 -behaviour(application).
20 -export([prep_stop/1]).
21 -export([start/2]).
22 -export([stop/1]).
23
24
25 start(_Type, _Args) ->
26 8 {ok, _} = cowboy:start_clear(
27 pgec,
28 [{port, pgec_config:http(port)}],
29 #{env => #{dispatch => dispatch()},
30 stream_handlers => [cowboy_telemetry_h, cowboy_stream_h]}),
31 8 {ok, _} = pgec_sup:start_link().
32
33
34 prep_stop(State) ->
35 8 ok = cowboy:stop_listener(pgec),
36 8 State.
37
38
39 stop(_State) ->
40 8 ok.
41
42
43 dispatch() ->
44 8 cowboy_router:compile([{'_', handlers()}]).
45
46
47 handlers() ->
48 8 pgec:priv_consult("handler.terms").
Line Hits Source