aboutsummaryrefslogtreecommitdiffstats
path: root/test/http_handler.erl
diff options
context:
space:
mode:
Diffstat (limited to 'test/http_handler.erl')
-rw-r--r--test/http_handler.erl12
1 files changed, 8 insertions, 4 deletions
diff --git a/test/http_handler.erl b/test/http_handler.erl
index 3882e17..76a85d4 100644
--- a/test/http_handler.erl
+++ b/test/http_handler.erl
@@ -4,11 +4,15 @@
-behaviour(cowboy_http_handler).
-export([init/3, handle/2, terminate/2]).
-init({_Transport, http}, Req, _Opts) ->
- {ok, Req, undefined}.
+-record(state, {headers, body}).
-handle(Req, State) ->
- {ok, Req2} = cowboy_http_req:reply(200, [], "http_handler", Req),
+init({_Transport, http}, Req, Opts) ->
+ Headers = proplists:get_value(headers, Opts, []),
+ Body = proplists:get_value(body, Opts, "http_handler"),
+ {ok, Req, #state{headers=Headers, body=Body}}.
+
+handle(Req, State=#state{headers=Headers, body=Body}) ->
+ {ok, Req2} = cowboy_http_req:reply(200, Headers, Body, Req),
{ok, Req2, State}.
terminate(_Req, _State) ->