Stage 9
This commit is contained in:
@@ -12,6 +12,7 @@ start(_StartType, _StartArgs) ->
|
||||
ok = infra_mnesia:init_tables(),
|
||||
ok = infra_mnesia:wait_for_tables(),
|
||||
start_http(),
|
||||
start_admin_http(),
|
||||
{ok, Pid};
|
||||
Error ->
|
||||
Error
|
||||
@@ -76,4 +77,30 @@ start_http() ->
|
||||
middlewares => Middlewares
|
||||
}),
|
||||
|
||||
io:format("HTTP server started on port ~p~n", [Port]).
|
||||
io:format("HTTP server started on port ~p~n", [Port]).
|
||||
|
||||
start_admin_http() ->
|
||||
Port = application:get_env(eventhub, admin_http_port, 8445),
|
||||
|
||||
Dispatch = cowboy_router:compile([
|
||||
{'_', [
|
||||
{"/admin/health", admin_handler_health, []},
|
||||
{"/admin/stats", admin_handler_stats, []},
|
||||
{"/admin/users", admin_handler_users, []},
|
||||
{"/admin/users/:id", admin_handler_user_by_id, []}
|
||||
]}
|
||||
]),
|
||||
|
||||
Middlewares = [
|
||||
cowboy_router,
|
||||
cowboy_handler
|
||||
],
|
||||
|
||||
Env = #{dispatch => Dispatch},
|
||||
|
||||
cowboy:start_clear(admin_http, [{port, Port}], #{
|
||||
env => Env,
|
||||
middlewares => Middlewares
|
||||
}),
|
||||
|
||||
io:format("Admin HTTP server started on port ~p~n", [Port]).
|
||||
Reference in New Issue
Block a user