aboutsummaryrefslogtreecommitdiffstats
path: root/test/handlers/echo_h.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-09-05 15:28:11 +0200
committerLoïc Hoguin <[email protected]>2017-09-05 15:28:11 +0200
commit9f5a1803da64978dfbadbd6629c41bb16fc6ec90 (patch)
tree95f63c583e99d383fad888a8d8ba87a82a292300 /test/handlers/echo_h.erl
parent2376983295569e897c82f2b4a63d1485beae7263 (diff)
downloadcowboy-9f5a1803da64978dfbadbd6629c41bb16fc6ec90.tar.gz
cowboy-9f5a1803da64978dfbadbd6629c41bb16fc6ec90.tar.bz2
cowboy-9f5a1803da64978dfbadbd6629c41bb16fc6ec90.zip
Add tests for direct Req access
Diffstat (limited to 'test/handlers/echo_h.erl')
-rw-r--r--test/handlers/echo_h.erl7
1 files changed, 5 insertions, 2 deletions
diff --git a/test/handlers/echo_h.erl b/test/handlers/echo_h.erl
index 5042ca8..b7a407b 100644
--- a/test/handlers/echo_h.erl
+++ b/test/handlers/echo_h.erl
@@ -55,8 +55,11 @@ echo(<<"match">>, Req, Opts) ->
end,
{ok, cowboy_req:reply(200, #{}, value_to_iodata(Value), Req), Opts};
echo(What, Req, Opts) ->
- F = binary_to_atom(What, latin1),
- Value = cowboy_req:F(Req),
+ Key = binary_to_atom(What, latin1),
+ Value = case cowboy_req:path(Req) of
+ <<"/direct/",_/bits>> -> maps:get(Key, Req);
+ _ -> cowboy_req:Key(Req)
+ end,
{ok, cowboy_req:reply(200, #{}, value_to_iodata(Value), Req), Opts}.
echo_arg(Arg0, Req, Opts) ->