aboutsummaryrefslogtreecommitdiffstats
path: root/test/handlers/echo_h.erl
diff options
context:
space:
mode:
Diffstat (limited to 'test/handlers/echo_h.erl')
-rw-r--r--test/handlers/echo_h.erl16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/handlers/echo_h.erl b/test/handlers/echo_h.erl
new file mode 100644
index 0000000..71408c3
--- /dev/null
+++ b/test/handlers/echo_h.erl
@@ -0,0 +1,16 @@
+%% This module echoes back the value the test is interested in.
+
+-module(echo_h).
+
+-export([init/2]).
+
+init(Req, Opts) ->
+ echo(cowboy_req:binding(key, Req), Req, Opts).
+
+echo(What, Req, Opts) ->
+ F = binary_to_atom(What, latin1),
+ Value = case cowboy_req:F(Req) of
+ V when is_integer(V) -> integer_to_binary(V);
+ V -> V
+ end,
+ {ok, cowboy_req:reply(200, [], Value, Req), Opts}.