aboutsummaryrefslogtreecommitdiffstats
path: root/doc/src/guide/loop_handlers.ezdoc
diff options
context:
space:
mode:
authorStefan Strigler <[email protected]>2014-10-08 16:49:18 +0200
committerStefan Strigler <[email protected]>2014-10-08 16:49:18 +0200
commit8fd3ff2d629fa13a52061e7db5c67a3ba6fe4429 (patch)
tree8337c1aff021ee40dccdac0c52a741b6bcb17929 /doc/src/guide/loop_handlers.ezdoc
parentb87150c713fe16601b314451b2fe25b62bd820bb (diff)
downloadcowboy-8fd3ff2d629fa13a52061e7db5c67a3ba6fe4429.tar.gz
cowboy-8fd3ff2d629fa13a52061e7db5c67a3ba6fe4429.tar.bz2
cowboy-8fd3ff2d629fa13a52061e7db5c67a3ba6fe4429.zip
change init/2 to return #state{} in documentation
Most examples returned 'Opts' as given by second argument to init. By using '#state{}' the examples make it more clear that this is what is being passed as 'State' to all subsequent callbacks (if any).
Diffstat (limited to 'doc/src/guide/loop_handlers.ezdoc')
-rw-r--r--doc/src/guide/loop_handlers.ezdoc14
1 files changed, 7 insertions, 7 deletions
diff --git a/doc/src/guide/loop_handlers.ezdoc b/doc/src/guide/loop_handlers.ezdoc
index 2324cfd..4be178e 100644
--- a/doc/src/guide/loop_handlers.ezdoc
+++ b/doc/src/guide/loop_handlers.ezdoc
@@ -34,8 +34,8 @@ process enter hibernation until a message is received.
This snippet enables the loop handler.
``` erlang
-init(Req, Opts) ->
- {cowboy_loop, Req, Opts}.
+init(Req, _Opts) ->
+ {cowboy_loop, Req, #state{}}.
```
However it is largely recommended that you set a timeout
@@ -43,8 +43,8 @@ value. The next example sets a timeout value of 30s and
also makes the process hibernate.
``` erlang
-init(Req, Opts) ->
- {cowboy_loop, Req, Opts, 30000, hibernate}.
+init(Req, _Opts) ->
+ {cowboy_loop, Req, #state{}, 30000, hibernate}.
```
:: Receive loop
@@ -94,9 +94,9 @@ a chunk is sent every time a `chunk` message is received,
and the loop is stopped by sending an `eof` message.
``` erlang
-init(Req, Opts) ->
- Req2 = cowboy_req:chunked_reply(200, [], Req),
- {cowboy_loop, Req2, Opts}.
+init(Req, _Opts) ->
+ Req2 = cowboy_req:chunked_reply(200, [], Req),
+ {cowboy_loop, Req2, #state{}}.
info(eof, Req, State) ->
{shutdown, Req, State};