diff options
Diffstat (limited to 'test/handlers/delay_hello_h.erl')
-rw-r--r-- | test/handlers/delay_hello_h.erl | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/test/handlers/delay_hello_h.erl b/test/handlers/delay_hello_h.erl index 7e59be6..ee3ee9c 100644 --- a/test/handlers/delay_hello_h.erl +++ b/test/handlers/delay_hello_h.erl @@ -4,6 +4,14 @@ -export([init/2]). -init(Req, Delay) -> +init(Req, Delay) when is_integer(Delay) -> + init(Req, #{delay => Delay}); +init(Req, Opts=#{delay := Delay}) -> + _ = case Opts of + #{notify_received := Pid} -> + Pid ! {request_received, maps:get(path, Req)}; + _ -> + ok + end, timer:sleep(Delay), {ok, cowboy_req:reply(200, #{}, <<"Hello world!">>, Req), Delay}. |