fix(api): uppercase api request method

This commit is contained in:
JimMoen 2022-11-14 17:55:17 +08:00
parent e667b564d8
commit 7b5340ce09
No known key found for this signature in database
GPG Key ID: 87A520B4F76BA86D
2 changed files with 8 additions and 2 deletions

View File

@ -124,7 +124,10 @@ handle_request(_Method, _Path, Req) ->
cowboy_req:reply(400, #{<<"content-type">> => <<"text/plain">>}, <<"Not found.">>, Req).
authorize_appid(Req) ->
authorize_appid(cowboy_req:method(Req), cowboy_req:path(Req), Req).
authorize_appid(
iolist_to_binary(string:uppercase(cowboy_req:method(Req))),
iolist_to_binary(cowboy_req:path(Req)),
Req).
authorize_appid(<<"GET">>, <<"/api/v4/emqx_prometheus">>, _Req) ->
true;

View File

@ -107,7 +107,10 @@ http_handlers() ->
%%--------------------------------------------------------------------
is_authorized(Req) ->
is_authorized(cowboy_req:method(Req), cowboy_req:path(Req), Req).
is_authorized(
iolist_to_binary(string:uppercase(cowboy_req:method(Req))),
iolist_to_binary(cowboy_req:path(Req)),
Req).
is_authorized(<<"GET">>, <<"/api/v4/emqx_prometheus">>, _Req) ->
true;