1%% Feel free to use, reuse and abuse the code in this file.
2
3%% @doc Chunked hello world handler.
4-module(toppage_handler).
5
6-export([init/3]).
7-export([handle/2]).
8-export([terminate/3]).
9
10init(_Transport, Req, []) ->
11	{ok, Req, undefined}.
12
13handle(Req, State) ->
14	{ok, Req2} = cowboy_req:chunked_reply(200, Req),
15	ok = cowboy_req:chunk("Hello\r\n", Req2),
16	ok = timer:sleep(1000),
17	ok = cowboy_req:chunk("World\r\n", Req2),
18	ok = timer:sleep(1000),
19	ok = cowboy_req:chunk("Chunked!\r\n", Req2),
20	{ok, Req2, State}.
21
22terminate(_Reason, _Req, _State) ->
23	ok.
24