diff options
Diffstat (limited to 'server/src/jchat_http_health.erl')
-rw-r--r-- | server/src/jchat_http_health.erl | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/server/src/jchat_http_health.erl b/server/src/jchat_http_health.erl new file mode 100644 index 0000000..4140f51 --- /dev/null +++ b/server/src/jchat_http_health.erl @@ -0,0 +1,21 @@ +-module(jchat_http_health). + +-export([init/2]). + +init(Req0, State) -> + Health = #{ + <<"status">> => <<"ok">>, + <<"timestamp">> => jchat_utils:now_iso8601(), + <<"version">> => <<"0.1.0">>, + <<"config">> => #{ + <<"api_domain">> => list_to_binary(jchat_config:api_domain()), + <<"web_domain">> => list_to_binary(jchat_config:web_domain()) + } + }, + + Req1 = cowboy_req:reply(200, #{ + <<"content-type">> => <<"application/json; charset=utf-8">>, + <<"access-control-allow-origin">> => <<"*">> + }, jchat_utils:json_encode(Health), Req0), + + {ok, Req1, State}. |