aboutsummaryrefslogtreecommitdiffstats
path: root/examples/cookie/src
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2016-06-14 16:23:51 +0200
committerLoïc Hoguin <[email protected]>2016-06-14 16:23:51 +0200
commit84fb85e2e4bc91d2dfc0da04674d96db34089a05 (patch)
tree386ea385dae9490cab9763387e4b93e9156f7f19 /examples/cookie/src
parenta55679b231b61e7d2269142efa337ae6face2343 (diff)
downloadcowboy-84fb85e2e4bc91d2dfc0da04674d96db34089a05.tar.gz
cowboy-84fb85e2e4bc91d2dfc0da04674d96db34089a05.tar.bz2
cowboy-84fb85e2e4bc91d2dfc0da04674d96db34089a05.zip
Fix cookie example
Diffstat (limited to 'examples/cookie/src')
-rw-r--r--examples/cookie/src/cookie_app.erl6
-rw-r--r--examples/cookie/src/toppage_handler.erl10
2 files changed, 8 insertions, 8 deletions
diff --git a/examples/cookie/src/cookie_app.erl b/examples/cookie/src/cookie_app.erl
index 91d1b95..8ce7fdd 100644
--- a/examples/cookie/src/cookie_app.erl
+++ b/examples/cookie/src/cookie_app.erl
@@ -16,9 +16,9 @@ start(_Type, _Args) ->
{'_', toppage_handler, []}
]}
]),
- {ok, _} = cowboy:start_http(http, 100, [{port, 8080}], [
- {env, [{dispatch, Dispatch}]}
- ]),
+ {ok, _} = cowboy:start_clear(http, 100, [{port, 8080}], #{
+ env => #{dispatch => Dispatch}
+ }),
cookie_sup:start_link().
stop(_State) ->
diff --git a/examples/cookie/src/toppage_handler.erl b/examples/cookie/src/toppage_handler.erl
index 745f626..e795cf8 100644
--- a/examples/cookie/src/toppage_handler.erl
+++ b/examples/cookie/src/toppage_handler.erl
@@ -6,7 +6,7 @@
-export([init/2]).
init(Req, Opts) ->
- NewValue = integer_to_list(random:uniform(1000000)),
+ NewValue = integer_to_list(rand:uniform(1000000)),
Req2 = cowboy_req:set_resp_cookie(
<<"server">>, NewValue, [{path, <<"/">>}], Req),
#{client := ClientCookie, server := ServerCookie}
@@ -15,7 +15,7 @@ init(Req, Opts) ->
{client, ClientCookie},
{server, ServerCookie}
]),
- Req3 = cowboy_req:reply(200,
- [{<<"content-type">>, <<"text/html">>}],
- Body, Req2),
- {ok, Req3, Opts}.
+ cowboy_req:reply(200, #{
+ <<"content-type">> => <<"text/html">>
+ }, Body, Req2),
+ {ok, Req2, Opts}.