Stage 10 final
This commit is contained in:
@@ -2,6 +2,17 @@
|
||||
|
||||
-export([init/2]).
|
||||
|
||||
init(Req, _Opts) ->
|
||||
Body = jsx:encode(#{status => <<"ok">>}),
|
||||
cowboy_req:reply(200, #{<<"content-type">> => <<"application/json">>}, Body, Req).
|
||||
init(Req, Opts) ->
|
||||
handle(Req, Opts).
|
||||
|
||||
handle(Req, _Opts) ->
|
||||
case cowboy_req:method(Req) of
|
||||
<<"GET">> ->
|
||||
Body = jsx:encode(#{status => <<"ok">>}),
|
||||
Req1 = cowboy_req:reply(200, #{<<"content-type">> => <<"application/json">>}, Body, Req),
|
||||
{ok, Req1, []};
|
||||
_ ->
|
||||
Body = jsx:encode(#{error => <<"Method not allowed">>}),
|
||||
Req1 = cowboy_req:reply(405, #{<<"content-type">> => <<"application/json">>}, Body, Req),
|
||||
{ok, Req1, []}
|
||||
end.
|
||||
Reference in New Issue
Block a user