This commit is contained in:
2026-04-20 21:04:16 +03:00
parent b24cbc97f3
commit 19f82768e4
18 changed files with 1851 additions and 131 deletions

View File

@@ -4,19 +4,14 @@
-export([start/2, stop/1]).
start(_StartType, _StartArgs) ->
% Запускаем Mnesia
application:ensure_all_started(mnesia),
application:ensure_all_started(cowboy),
case infra_sup:start_link() of
{ok, Pid} ->
% Инициализируем таблицы и ждем готовности
ok = infra_mnesia:init_tables(),
ok = infra_mnesia:wait_for_tables(),
% Запускаем HTTP-сервер
start_http(),
{ok, Pid};
Error ->
Error
@@ -25,11 +20,9 @@ start(_StartType, _StartArgs) ->
stop(_State) ->
ok.
%% Internal functions
start_http() ->
Port = application:get_env(eventhub, http_port, 8080),
% Настройка маршрутов
Dispatch = cowboy_router:compile([
{'_', [
{"/health", handler_health, []},
@@ -38,6 +31,7 @@ start_http() ->
{"/v1/refresh", handler_refresh, []},
{"/v1/user/me", handler_user_me, []},
{"/v1/user/bookings", handler_user_bookings, []},
{"/v1/search", handler_search, []},
{"/v1/calendars", handler_calendars, []},
{"/v1/calendars/:id", handler_calendar_by_id, []},
{"/v1/calendars/:calendar_id/events", handler_events, []},
@@ -49,7 +43,6 @@ start_http() ->
]}
]),
% Настройка middleware
Middlewares = [
cowboy_router,
cowboy_handler