aboutsummaryrefslogtreecommitdiffstats
path: root/examples/eventsource/src
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2016-06-14 17:05:41 +0200
committerLoïc Hoguin <[email protected]>2016-06-14 17:05:41 +0200
commit5003bae369901a6c771075ac4ef600d49b019570 (patch)
treeb4e5b9c9a193c3880732d0addb209ee6f80cc9cb /examples/eventsource/src
parent84fb85e2e4bc91d2dfc0da04674d96db34089a05 (diff)
downloadcowboy-5003bae369901a6c771075ac4ef600d49b019570.tar.gz
cowboy-5003bae369901a6c771075ac4ef600d49b019570.tar.bz2
cowboy-5003bae369901a6c771075ac4ef600d49b019570.zip
Fix eventsource example
Diffstat (limited to 'examples/eventsource/src')
-rw-r--r--examples/eventsource/src/eventsource_app.erl6
-rw-r--r--examples/eventsource/src/eventsource_handler.erl5
2 files changed, 6 insertions, 5 deletions
diff --git a/examples/eventsource/src/eventsource_app.erl b/examples/eventsource/src/eventsource_app.erl
index 6ee8611..a5f4289 100644
--- a/examples/eventsource/src/eventsource_app.erl
+++ b/examples/eventsource/src/eventsource_app.erl
@@ -17,9 +17,9 @@ start(_Type, _Args) ->
{"/", cowboy_static, {priv_file, eventsource, "index.html"}}
]}
]),
- {ok, _} = cowboy:start_http(http, 100, [{port, 8080}], [
- {env, [{dispatch, Dispatch}]}
- ]),
+ {ok, _} = cowboy:start_clear(http, 100, [{port, 8080}], #{
+ env => #{dispatch => Dispatch}
+ }),
eventsource_sup:start_link().
stop(_State) ->
diff --git a/examples/eventsource/src/eventsource_handler.erl b/examples/eventsource/src/eventsource_handler.erl
index 0e06ede..6dced4b 100644
--- a/examples/eventsource/src/eventsource_handler.erl
+++ b/examples/eventsource/src/eventsource_handler.erl
@@ -7,8 +7,9 @@
-export([info/3]).
init(Req, Opts) ->
- Headers = [{<<"content-type">>, <<"text/event-stream">>}],
- Req2 = cowboy_req:chunked_reply(200, Headers, Req),
+ Req2 = cowboy_req:chunked_reply(200, #{
+ <<"content-type">> => <<"text/event-stream">>
+ }, Req),
erlang:send_after(1000, self(), {message, "Tick"}),
{cowboy_loop, Req2, Opts, 5000}.