diff options
Diffstat (limited to 'examples/echo_post/src/toppage_handler.erl')
-rw-r--r-- | examples/echo_post/src/toppage_handler.erl | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/examples/echo_post/src/toppage_handler.erl b/examples/echo_post/src/toppage_handler.erl index de75e5e..a84bfe5 100644 --- a/examples/echo_post/src/toppage_handler.erl +++ b/examples/echo_post/src/toppage_handler.erl @@ -14,16 +14,19 @@ init(Req, Opts) -> maybe_echo(<<"POST">>, true, Req) -> {ok, PostVals, Req2} = cowboy_req:body_qs(Req), Echo = proplists:get_value(<<"echo">>, PostVals), - echo(Echo, Req2); + echo(Echo, Req2), + Req2; maybe_echo(<<"POST">>, false, Req) -> - cowboy_req:reply(400, [], <<"Missing body.">>, Req); + cowboy_req:reply(400, [], <<"Missing body.">>, Req), + Req; maybe_echo(_, _, Req) -> %% Method not allowed. - cowboy_req:reply(405, Req). + cowboy_req:reply(405, Req), + Req. echo(undefined, Req) -> cowboy_req:reply(400, [], <<"Missing echo parameter.">>, Req); echo(Echo, Req) -> - cowboy_req:reply(200, [ - {<<"content-type">>, <<"text/plain; charset=utf-8">>} - ], Echo, Req). + cowboy_req:reply(200, #{ + <<"content-type">> => <<"text/plain; charset=utf-8">> + }, Echo, Req). |