From 1ca27e93a979369361d367d8a767cd6fc255cdd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9=20=D0=A1=D0=B0?= =?UTF-8?q?=D0=B1=D0=B8=D0=BB=D0=B8=D0=BD?= Date: Wed, 29 Apr 2026 11:17:53 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B1=D0=B5=D0=B7=D0=BE=D0=BF=D0=B0=D1=81=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D0=B8=20=D0=B8=20=D0=BE=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D0=BA=D0=B8=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE?= =?UTF-8?q?=D0=BA.=20=D0=AD=D1=82=D0=B0=D0=BF=202.=20https://git.sabilin.c?= =?UTF-8?q?om/EventHub/EventHubBack/issues/8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers/admin/admin_handler_admins.erl | 9 +++++++-- src/handlers/admin/admin_handler_banned_words.erl | 7 ++++++- src/handlers/admin/admin_handler_reports.erl | 7 ++++++- src/handlers/admin/admin_handler_reviews.erl | 7 ++++++- src/handlers/admin/admin_handler_subscriptions.erl | 7 ++++++- src/handlers/admin/admin_handler_ticket_stats.erl | 7 ++++++- src/handlers/admin/admin_handler_tickets.erl | 7 ++++++- src/handlers/admin/admin_handler_users.erl | 7 ++++++- 8 files changed, 49 insertions(+), 9 deletions(-) diff --git a/src/handlers/admin/admin_handler_admins.erl b/src/handlers/admin/admin_handler_admins.erl index 6e5ee54..f70326b 100644 --- a/src/handlers/admin/admin_handler_admins.erl +++ b/src/handlers/admin/admin_handler_admins.erl @@ -102,9 +102,14 @@ datetime_to_iso8601({{Y,M,D},{H,Min,S}}) -> datetime_to_iso8601(_) -> null. send_json(Req, Status, Data) -> + Headers = #{ + <<"content-type">> => <<"application/json">>, + <<"access-control-allow-origin">> => <<"*">>, + <<"access-control-expose-headers">> => <<"Content-Range">> + }, Body = jsx:encode(Data), - Req2 = cowboy_req:reply(Status, #{<<"content-type">> => <<"application/json">>}, Body, Req), - {ok, Req2, []}. + cowboy_req:reply(Status, Headers, Body, Req), + {ok, Body, []}. send_error(Req, Code, Message) -> Body = jsx:encode(#{error => Message}), diff --git a/src/handlers/admin/admin_handler_banned_words.erl b/src/handlers/admin/admin_handler_banned_words.erl index 9ab8c34..0124067 100644 --- a/src/handlers/admin/admin_handler_banned_words.erl +++ b/src/handlers/admin/admin_handler_banned_words.erl @@ -117,8 +117,13 @@ datetime_to_iso8601({{Year, Month, Day}, {Hour, Minute, Second}}) -> datetime_to_iso8601(undefined) -> undefined. send_json(Req, Status, Data) -> + Headers = #{ + <<"content-type">> => <<"application/json">>, + <<"access-control-allow-origin">> => <<"*">>, + <<"access-control-expose-headers">> => <<"Content-Range">> + }, Body = jsx:encode(Data), - cowboy_req:reply(Status, #{<<"content-type">> => <<"application/json">>}, Body, Req), + cowboy_req:reply(Status, Headers, Body, Req), {ok, Body, []}. send_error(Req, Status, Message) -> diff --git a/src/handlers/admin/admin_handler_reports.erl b/src/handlers/admin/admin_handler_reports.erl index ab5a3cb..e79d6ec 100644 --- a/src/handlers/admin/admin_handler_reports.erl +++ b/src/handlers/admin/admin_handler_reports.erl @@ -94,8 +94,13 @@ datetime_to_iso8601({{Year, Month, Day}, {Hour, Minute, Second}}) -> datetime_to_iso8601(undefined) -> undefined. send_json(Req, Status, Data) -> + Headers = #{ + <<"content-type">> => <<"application/json">>, + <<"access-control-allow-origin">> => <<"*">>, + <<"access-control-expose-headers">> => <<"Content-Range">> + }, Body = jsx:encode(Data), - cowboy_req:reply(Status, #{<<"content-type">> => <<"application/json">>}, Body, Req), + cowboy_req:reply(Status, Headers, Body, Req), {ok, Body, []}. send_error(Req, Status, Message) -> diff --git a/src/handlers/admin/admin_handler_reviews.erl b/src/handlers/admin/admin_handler_reviews.erl index ce78726..e104f24 100644 --- a/src/handlers/admin/admin_handler_reviews.erl +++ b/src/handlers/admin/admin_handler_reviews.erl @@ -78,8 +78,13 @@ datetime_to_iso8601({{Year, Month, Day}, {Hour, Minute, Second}}) -> datetime_to_iso8601(undefined) -> undefined. send_json(Req, Status, Data) -> + Headers = #{ + <<"content-type">> => <<"application/json">>, + <<"access-control-allow-origin">> => <<"*">>, + <<"access-control-expose-headers">> => <<"Content-Range">> + }, Body = jsx:encode(Data), - cowboy_req:reply(Status, #{<<"content-type">> => <<"application/json">>}, Body, Req), + cowboy_req:reply(Status, Headers, Body, Req), {ok, Body, []}. send_error(Req, Status, Message) -> diff --git a/src/handlers/admin/admin_handler_subscriptions.erl b/src/handlers/admin/admin_handler_subscriptions.erl index ddc9298..dde61b9 100644 --- a/src/handlers/admin/admin_handler_subscriptions.erl +++ b/src/handlers/admin/admin_handler_subscriptions.erl @@ -141,8 +141,13 @@ datetime_to_iso8601({{Year, Month, Day}, {Hour, Minute, Second}}) -> datetime_to_iso8601(undefined) -> undefined. send_json(Req, Status, Data) -> + Headers = #{ + <<"content-type">> => <<"application/json">>, + <<"access-control-allow-origin">> => <<"*">>, + <<"access-control-expose-headers">> => <<"Content-Range">> + }, Body = jsx:encode(Data), - cowboy_req:reply(Status, #{<<"content-type">> => <<"application/json">>}, Body, Req), + cowboy_req:reply(Status, Headers, Body, Req), {ok, Body, []}. send_error(Req, Status, Message) -> diff --git a/src/handlers/admin/admin_handler_ticket_stats.erl b/src/handlers/admin/admin_handler_ticket_stats.erl index c12d384..2871045 100644 --- a/src/handlers/admin/admin_handler_ticket_stats.erl +++ b/src/handlers/admin/admin_handler_ticket_stats.erl @@ -31,8 +31,13 @@ auth_admin(Req) -> end. send_json(Req, Status, Data) -> + Headers = #{ + <<"content-type">> => <<"application/json">>, + <<"access-control-allow-origin">> => <<"*">>, + <<"access-control-expose-headers">> => <<"Content-Range">> + }, Body = jsx:encode(Data), - cowboy_req:reply(Status, #{<<"content-type">> => <<"application/json">>}, Body, Req), + cowboy_req:reply(Status, Headers, Body, Req), {ok, Body, []}. send_error(Req, Status, Message) -> diff --git a/src/handlers/admin/admin_handler_tickets.erl b/src/handlers/admin/admin_handler_tickets.erl index e073dd8..aea79fa 100644 --- a/src/handlers/admin/admin_handler_tickets.erl +++ b/src/handlers/admin/admin_handler_tickets.erl @@ -141,8 +141,13 @@ datetime_to_iso8601({{Year, Month, Day}, {Hour, Minute, Second}}) -> datetime_to_iso8601(undefined) -> undefined. send_json(Req, Status, Data) -> + Headers = #{ + <<"content-type">> => <<"application/json">>, + <<"access-control-allow-origin">> => <<"*">>, + <<"access-control-expose-headers">> => <<"Content-Range">> + }, Body = jsx:encode(Data), - cowboy_req:reply(Status, #{<<"content-type">> => <<"application/json">>}, Body, Req), + cowboy_req:reply(Status, Headers, Body, Req), {ok, Body, []}. send_error(Req, Status, Message) -> diff --git a/src/handlers/admin/admin_handler_users.erl b/src/handlers/admin/admin_handler_users.erl index 554888f..d23a7ab 100644 --- a/src/handlers/admin/admin_handler_users.erl +++ b/src/handlers/admin/admin_handler_users.erl @@ -46,8 +46,13 @@ datetime_to_iso8601({{Y,M,D},{H,Min,S}}) -> datetime_to_iso8601(_) -> null. send_json(Req, Status, Data) -> + Headers = #{ + <<"content-type">> => <<"application/json">>, + <<"access-control-allow-origin">> => <<"*">>, + <<"access-control-expose-headers">> => <<"Content-Range">> + }, Body = jsx:encode(Data), - cowboy_req:reply(Status, #{<<"content-type">> => <<"application/json">>}, Body, Req), + cowboy_req:reply(Status, Headers, Body, Req), {ok, Body, []}. send_error(Req, Status, Message) ->