aboutsummaryrefslogtreecommitdiffstats
path: root/test/handlers/sse_lone_id_h.erl
blob: 3684fa9bd04bb5789cb54545925857240f84cc97 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
%% This module implements a loop handler that sends
%% a lone id: line.

-module(sse_lone_id_h).

-export([init/2]).
-export([info/3]).

init(Req, State) ->
	self() ! timeout,
	{cowboy_loop, cowboy_req:stream_reply(200, #{
		<<"content-type">> => <<"text/event-stream">>
	}, Req), State}.

info(timeout, Req, State) ->
	cowboy_req:stream_events(#{
		id => <<"hello">>
	}, nofin, Req),
	{stop, Req, State}.