aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/chunked_hello_world/src/toppage_handler.erl8
-rw-r--r--examples/cookie/src/toppage_handler.erl4
-rw-r--r--examples/echo_post/src/toppage_handler.erl2
-rw-r--r--examples/eventsource/src/eventsource_handler.erl6
-rw-r--r--examples/rest_pastebin/src/toppage_handler.erl2
5 files changed, 11 insertions, 11 deletions
diff --git a/examples/chunked_hello_world/src/toppage_handler.erl b/examples/chunked_hello_world/src/toppage_handler.erl
index 22e52b9..d492d95 100644
--- a/examples/chunked_hello_world/src/toppage_handler.erl
+++ b/examples/chunked_hello_world/src/toppage_handler.erl
@@ -6,10 +6,10 @@
-export([init/2]).
init(Req, Opts) ->
- cowboy_req:chunked_reply(200, Req),
- cowboy_req:chunk("Hello\r\n", Req),
+ cowboy_req:stream_reply(200, Req),
+ cowboy_req:stream_body("Hello\r\n", nofin, Req),
timer:sleep(1000),
- cowboy_req:chunk("World\r\n", Req),
+ cowboy_req:stream_body("World\r\n", nofin, Req),
timer:sleep(1000),
- cowboy_req:chunk("Chunked!\r\n", Req),
+ cowboy_req:stream_body("Chunked!\r\n", fin, Req),
{ok, Req, Opts}.
diff --git a/examples/cookie/src/toppage_handler.erl b/examples/cookie/src/toppage_handler.erl
index e795cf8..6af8dcc 100644
--- a/examples/cookie/src/toppage_handler.erl
+++ b/examples/cookie/src/toppage_handler.erl
@@ -7,8 +7,8 @@
init(Req, Opts) ->
NewValue = integer_to_list(rand:uniform(1000000)),
- Req2 = cowboy_req:set_resp_cookie(
- <<"server">>, NewValue, [{path, <<"/">>}], Req),
+ Req2 = cowboy_req:set_resp_cookie(<<"server">>, NewValue,
+ #{path => <<"/">>}, Req),
#{client := ClientCookie, server := ServerCookie}
= cowboy_req:match_cookies([{client, [], <<>>}, {server, [], <<>>}], Req2),
{ok, Body} = toppage_dtl:render([
diff --git a/examples/echo_post/src/toppage_handler.erl b/examples/echo_post/src/toppage_handler.erl
index a84bfe5..f52b6d4 100644
--- a/examples/echo_post/src/toppage_handler.erl
+++ b/examples/echo_post/src/toppage_handler.erl
@@ -12,7 +12,7 @@ init(Req, Opts) ->
{ok, Req2, Opts}.
maybe_echo(<<"POST">>, true, Req) ->
- {ok, PostVals, Req2} = cowboy_req:body_qs(Req),
+ {ok, PostVals, Req2} = cowboy_req:read_urlencoded_body(Req),
Echo = proplists:get_value(<<"echo">>, PostVals),
echo(Echo, Req2),
Req2;
diff --git a/examples/eventsource/src/eventsource_handler.erl b/examples/eventsource/src/eventsource_handler.erl
index 6dced4b..fec2516 100644
--- a/examples/eventsource/src/eventsource_handler.erl
+++ b/examples/eventsource/src/eventsource_handler.erl
@@ -7,14 +7,14 @@
-export([info/3]).
init(Req, Opts) ->
- Req2 = cowboy_req:chunked_reply(200, #{
+ cowboy_req:stream_reply(200, #{
<<"content-type">> => <<"text/event-stream">>
}, Req),
erlang:send_after(1000, self(), {message, "Tick"}),
- {cowboy_loop, Req2, Opts, 5000}.
+ {cowboy_loop, Req, Opts, 5000}.
info({message, Msg}, Req, State) ->
- cowboy_req:chunk(["id: ", id(), "\ndata: ", Msg, "\n\n"], Req),
+ cowboy_req:stream_body(["id: ", id(), "\ndata: ", Msg, "\n\n"], nofin, Req),
erlang:send_after(1000, self(), {message, "Tick"}),
{ok, Req, State}.
diff --git a/examples/rest_pastebin/src/toppage_handler.erl b/examples/rest_pastebin/src/toppage_handler.erl
index 86bafb7..ddf4c50 100644
--- a/examples/rest_pastebin/src/toppage_handler.erl
+++ b/examples/rest_pastebin/src/toppage_handler.erl
@@ -44,7 +44,7 @@ resource_exists(Req, _State) ->
create_paste(Req, State) ->
PasteID = new_paste_id(),
- {ok, [{<<"paste">>, Paste}], Req2} = cowboy_req:body_qs(Req),
+ {ok, [{<<"paste">>, Paste}], Req2} = cowboy_req:read_urlencoded_body(Req),
ok = file:write_file(full_path(PasteID), Paste),
case cowboy_req:method(Req2) of
<<"POST">> ->