blob: ee3ee9c8629d69b8ba3b172347a7e6375382cf34 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
%% This module sends a hello world response after a delay.
-module(delay_hello_h).
-export([init/2]).
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}.
|