summaryrefslogtreecommitdiffstats
path: root/docs/en/cowboy/2.0/guide/loop_handlers.asciidoc
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2016-08-29 12:39:49 +0200
committerLoïc Hoguin <[email protected]>2016-08-29 12:40:03 +0200
commitc807880f7ac73f813b2660ea81a00f7712a4e793 (patch)
treeba1d09e9b177f230665a80513b33fbd532000ce4 /docs/en/cowboy/2.0/guide/loop_handlers.asciidoc
parentb1df25a7d9cda697513650659b781b55b40898f8 (diff)
downloadninenines.eu-c807880f7ac73f813b2660ea81a00f7712a4e793.tar.gz
ninenines.eu-c807880f7ac73f813b2660ea81a00f7712a4e793.tar.bz2
ninenines.eu-c807880f7ac73f813b2660ea81a00f7712a4e793.zip
Add old mailing list archives
Diffstat (limited to 'docs/en/cowboy/2.0/guide/loop_handlers.asciidoc')
-rw-r--r--docs/en/cowboy/2.0/guide/loop_handlers.asciidoc18
1 files changed, 10 insertions, 8 deletions
diff --git a/docs/en/cowboy/2.0/guide/loop_handlers.asciidoc b/docs/en/cowboy/2.0/guide/loop_handlers.asciidoc
index 58c42233..c0195ea0 100644
--- a/docs/en/cowboy/2.0/guide/loop_handlers.asciidoc
+++ b/docs/en/cowboy/2.0/guide/loop_handlers.asciidoc
@@ -1,6 +1,8 @@
[[loop_handlers]]
== Loop handlers
+// @todo This description needs to be updated.
+
Loop handlers are a special kind of HTTP handlers used when the
response can not be sent right away. The handler enters instead
a receive loop waiting for the right message before it can send
@@ -36,8 +38,8 @@ This snippet enables the loop handler.
[source,erlang]
----
-init(Req, _Opts) ->
- {cowboy_loop, Req, #state{}}.
+init(Req, State) ->
+ {cowboy_loop, Req, State}.
----
However it is largely recommended that you set a timeout
@@ -46,8 +48,8 @@ also makes the process hibernate.
[source,erlang]
----
-init(Req, _Opts) ->
- {cowboy_loop, Req, #state{}, 30000, hibernate}.
+init(Req, State) ->
+ {cowboy_loop, Req, State, 30000, hibernate}.
----
=== Receive loop
@@ -64,8 +66,8 @@ message otherwise.
[source,erlang]
----
info({reply, Body}, Req, State) ->
- Req2 = cowboy_req:reply(200, [], Body, Req),
- {stop, Req2, State};
+ cowboy_req:reply(200, [], Body, Req),
+ {stop, Req, State};
info(_Msg, Req, State) ->
{ok, Req, State, hibernate}.
----
@@ -99,9 +101,9 @@ and the loop is stopped by sending an `eof` message.
[source,erlang]
----
-init(Req, _Opts) ->
+init(Req, State) ->
Req2 = cowboy_req:chunked_reply(200, [], Req),
- {cowboy_loop, Req2, #state{}}.
+ {cowboy_loop, Req2, State}.
info(eof, Req, State) ->
{stop, Req, State};