This commit is contained in:
anlicheng 2024-10-14 17:52:26 +08:00
parent 28ff371de5
commit 6f60cdbd82

View File

@ -18,7 +18,8 @@ init(Req0, Opts) ->
{ok, ReqBody, Req1} = parse_body(Req0),
Sign = cowboy_req:header(<<"sign">>, Req1, <<>>),
case njau_bot_signer:sign(ReqBody) =:= Sign of
BodySign = njau_bot_signer:sign(ReqBody),
case BodySign =:= Sign of
true ->
{ok, StatusCode, Resp} = handle_request(Method, Path, ReqBody),
lager:debug("[http_protocol] request path: ~p, post_params: ~p, response: ~ts",
@ -28,7 +29,7 @@ init(Req0, Opts) ->
}, Resp, Req1),
{ok, Req2, Opts};
false ->
lager:debug("[api_handler] invalid sign: ~p", [Sign]),
lager:debug("[api_handler] invalid sign: ~p, body sign: ~p, request body: ~p", [Sign, BodySign, ReqBody]),
Req2 = cowboy_req:reply(500, #{
<<"Content-Type">> => <<"text/html;charset=utf-8">>
}, <<"Internal Server Error">>, Req1),