diff --git a/apps/njau_bot/src/http_handler/api_handler.erl b/apps/njau_bot/src/http_handler/api_handler.erl index b0e8fa9..2f8a653 100644 --- a/apps/njau_bot/src/http_handler/api_handler.erl +++ b/apps/njau_bot/src/http_handler/api_handler.erl @@ -25,10 +25,6 @@ init(Req0, Opts) -> }, Resp, Req1), {ok, Req2, Opts}. -%% 健康检查 -handle_request("GET", "/api/health_check", _) -> - {ok, 200, <<"OK">>}; - %% 场地信息 handle_request("POST", "/api/device_info/storeInfo", ReqBody) when is_binary(ReqBody) -> #{<<"storeInfos">> := StoreInfos} = jiffy:decode(ReqBody, [return_maps]), diff --git a/apps/njau_bot/src/http_handler/health_handler.erl b/apps/njau_bot/src/http_handler/health_handler.erl new file mode 100644 index 0000000..a5950ee --- /dev/null +++ b/apps/njau_bot/src/http_handler/health_handler.erl @@ -0,0 +1,19 @@ +%%%------------------------------------------------------------------- +%%% @author licheng5 +%%% @copyright (C) 2020, +%%% @doc +%%% +%%% @end +%%% Created : 26. 4月 2020 3:36 下午 +%%%------------------------------------------------------------------- +-module(health_handler). +-author("licheng5"). + +%% API +-export([init/2]). + +init(Req0, Opts) -> + Req1 = cowboy_req:reply(200, #{ + <<"Content-Type">> => <<"text/plain">> + }, <<"OK">>, Req0), + {ok, Req1, Opts}. \ No newline at end of file diff --git a/apps/njau_bot/src/njau_bot_app.erl b/apps/njau_bot/src/njau_bot_app.erl index fc73f3b..aeb9fd9 100644 --- a/apps/njau_bot/src/njau_bot_app.erl +++ b/apps/njau_bot/src/njau_bot_app.erl @@ -35,7 +35,8 @@ start_http_server() -> Dispatcher = cowboy_router:compile([ {'_', [ - {"/api/[...]", api_handler, []} + {"/api/device_info/[...]", api_handler, []}, + {"/health_check", health_handler, []} ]} ]),