add health check
This commit is contained in:
parent
b74349e550
commit
35082a748b
@ -25,10 +25,6 @@ init(Req0, Opts) ->
|
|||||||
}, Resp, Req1),
|
}, Resp, Req1),
|
||||||
{ok, Req2, Opts}.
|
{ok, Req2, Opts}.
|
||||||
|
|
||||||
%% 健康检查
|
|
||||||
handle_request("GET", "/api/health_check", _) ->
|
|
||||||
{ok, 200, <<"OK">>};
|
|
||||||
|
|
||||||
%% 场地信息
|
%% 场地信息
|
||||||
handle_request("POST", "/api/device_info/storeInfo", ReqBody) when is_binary(ReqBody) ->
|
handle_request("POST", "/api/device_info/storeInfo", ReqBody) when is_binary(ReqBody) ->
|
||||||
#{<<"storeInfos">> := StoreInfos} = jiffy:decode(ReqBody, [return_maps]),
|
#{<<"storeInfos">> := StoreInfos} = jiffy:decode(ReqBody, [return_maps]),
|
||||||
|
|||||||
19
apps/njau_bot/src/http_handler/health_handler.erl
Normal file
19
apps/njau_bot/src/http_handler/health_handler.erl
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
%%%-------------------------------------------------------------------
|
||||||
|
%%% @author licheng5
|
||||||
|
%%% @copyright (C) 2020, <COMPANY>
|
||||||
|
%%% @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}.
|
||||||
@ -35,7 +35,8 @@ start_http_server() ->
|
|||||||
|
|
||||||
Dispatcher = cowboy_router:compile([
|
Dispatcher = cowboy_router:compile([
|
||||||
{'_', [
|
{'_', [
|
||||||
{"/api/[...]", api_handler, []}
|
{"/api/device_info/[...]", api_handler, []},
|
||||||
|
{"/health_check", health_handler, []}
|
||||||
]}
|
]}
|
||||||
]),
|
]),
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user