add health check

This commit is contained in:
anlicheng 2025-09-05 16:41:27 +08:00
parent b74349e550
commit 35082a748b
3 changed files with 21 additions and 5 deletions

View File

@ -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]),

View 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}.

View File

@ -35,7 +35,8 @@ start_http_server() ->
Dispatcher = cowboy_router:compile([
{'_', [
{"/api/[...]", api_handler, []}
{"/api/device_info/[...]", api_handler, []},
{"/health_check", health_handler, []}
]}
]),