aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/src/guide/getting_started.ezdoc2
-rw-r--r--doc/src/guide/handlers.ezdoc16
-rw-r--r--doc/src/guide/loop_handlers.ezdoc14
-rw-r--r--doc/src/guide/middlewares.ezdoc2
-rw-r--r--doc/src/guide/rest_handlers.ezdoc4
-rw-r--r--doc/src/guide/sub_protocols.ezdoc8
-rw-r--r--doc/src/guide/ws_handlers.ezdoc4
-rw-r--r--doc/src/manual/cowboy_websocket.ezdoc16
-rw-r--r--doc/src/specs/rfc7230_server.ezdoc8
9 files changed, 29 insertions, 45 deletions
diff --git a/doc/src/guide/getting_started.ezdoc b/doc/src/guide/getting_started.ezdoc
index a959b45..deb7bf2 100644
--- a/doc/src/guide/getting_started.ezdoc
+++ b/doc/src/guide/getting_started.ezdoc
@@ -121,7 +121,7 @@ start(_Type, _Args) ->
Dispatch = cowboy_router:compile([
{'_', [{"/", hello_handler, []}]}
]),
- cowboy:start_http(my_http_listener, 100, [{port, 8080}],
+ {ok, _} = cowboy:start_http(my_http_listener, 100, [{port, 8080}],
[{env, [{dispatch, Dispatch}]}]
),
hello_erlang_sup:start_link().
diff --git a/doc/src/guide/handlers.ezdoc b/doc/src/guide/handlers.ezdoc
index c0fb97e..9336488 100644
--- a/doc/src/guide/handlers.ezdoc
+++ b/doc/src/guide/handlers.ezdoc
@@ -14,8 +14,8 @@ defined during the ^"router configuration^routing^.
A handler that does nothing would look like this:
``` erlang
-init(Req, Opts) ->
- {ok, Req, Opts}.
+init(Req, _Opts) ->
+ {ok, Req, #state{}}.
```
Despite sending no reply, a `204 No Content` reply will be
@@ -25,11 +25,11 @@ sent for every request.
We need to use the Req object for sending a reply.
``` erlang
-init(Req, Opts) ->
+init(Req, _Opts) ->
Req2 = cowboy_req:reply(200, [
{<<"content-type">>, <<"text/plain">>}
], <<"Hello World!">>, Req),
- {ok, Req2, Opts}.
+ {ok, Req2, #state{}}.
```
As you can see we return a 3-tuple. `ok` means that the
@@ -60,15 +60,15 @@ return the name of the handler type you want to use. The
following snippet switches to a Websocket handler:
``` erlang
-init(Req, Opts) ->
- {cowboy_websocket, Req, Opts}.
+init(Req, _Opts) ->
+ {cowboy_websocket, Req, #state{}}.
```
You can also switch to your own custom handler type:
``` erlang
-init(Req, Opts) ->
- {my_handler_type, Req, Opts}.
+init(Req, _Opts) ->
+ {my_handler_type, Req, #state{}}.
```
How to implement a custom handler type is described in the
diff --git a/doc/src/guide/loop_handlers.ezdoc b/doc/src/guide/loop_handlers.ezdoc
index 879013b..47893a9 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) ->
{stop, Req, State};
diff --git a/doc/src/guide/middlewares.ezdoc b/doc/src/guide/middlewares.ezdoc
index 35e9ea9..8b047d7 100644
--- a/doc/src/guide/middlewares.ezdoc
+++ b/doc/src/guide/middlewares.ezdoc
@@ -19,7 +19,7 @@ It is defined in the `cowboy_middleware` behavior.
This callback has two arguments. The first is the `Req` object.
The second is the environment.
-Middlewares can return one of four different values:
+Middlewares can return one of three different values:
* `{ok, Req, Env}` to continue the request processing
* `{suspend, Module, Function, Args}` to hibernate
diff --git a/doc/src/guide/rest_handlers.ezdoc b/doc/src/guide/rest_handlers.ezdoc
index e09790a..e6bb092 100644
--- a/doc/src/guide/rest_handlers.ezdoc
+++ b/doc/src/guide/rest_handlers.ezdoc
@@ -13,8 +13,8 @@ to all handlers. To use REST for the current request, this function
must return a `cowboy_rest` tuple.
``` erlang
-init(Req, Opts) ->
- {cowboy_rest, Req, Opts}.
+init(Req, _Opts) ->
+ {cowboy_rest, Req, #state{}}.
```
Cowboy will then switch to the REST protocol and start executing
diff --git a/doc/src/guide/sub_protocols.ezdoc b/doc/src/guide/sub_protocols.ezdoc
index d34f21e..54e57aa 100644
--- a/doc/src/guide/sub_protocols.ezdoc
+++ b/doc/src/guide/sub_protocols.ezdoc
@@ -14,8 +14,8 @@ the name of the sub protocol module. Everything past this point
is handled by the sub protocol.
``` erlang
-init(Req, Opts) ->
- {cowboy_websocket, Req, Opts}.
+init(Req, _Opts) ->
+ {cowboy_websocket, Req, #state{}}.
```
The return value may also have a `Timeout` value and/or the
@@ -28,8 +28,8 @@ protocol, sets the timeout value to 5 seconds and enables
hibernation:
``` erlang
-init(Req, Opts) ->
- {my_protocol, Req, Opts, 5000, hibernate}.
+init(Req, _Opts) ->
+ {my_protocol, Req, #state{}, 5000, hibernate}.
```
If a sub protocol does not make use of these options, it should
diff --git a/doc/src/guide/ws_handlers.ezdoc b/doc/src/guide/ws_handlers.ezdoc
index 4cdf526..a0cfc29 100644
--- a/doc/src/guide/ws_handlers.ezdoc
+++ b/doc/src/guide/ws_handlers.ezdoc
@@ -16,8 +16,8 @@ to all handlers. To establish a Websocket connection, this function
must return a `ws` tuple.
``` erlang
-init(Req, Opts) ->
- {cowboy_websocket, Req, Opts}.
+init(Req, _Opts) ->
+ {cowboy_websocket, Req, #state{}}.
```
Upon receiving this tuple, Cowboy will switch to the code
diff --git a/doc/src/manual/cowboy_websocket.ezdoc b/doc/src/manual/cowboy_websocket.ezdoc
index 8aac4cf..2519dba 100644
--- a/doc/src/manual/cowboy_websocket.ezdoc
+++ b/doc/src/manual/cowboy_websocket.ezdoc
@@ -22,18 +22,6 @@ Cowboy will terminate the process right after closing the
Websocket connection. This means that there is no real need to
perform any cleanup in the optional `terminate/3` callback.
-:: Types
-
-: close_code() = 1000..4999
-
-Reason for closing the connection.
-
-: frame() = close | ping | pong
- | {text | binary | close | ping | pong, iodata()}
- | {close, close_code(), iodata()}
-
-Frames that can be sent to the client.
-
:: Meta values
: websocket_compress
@@ -118,7 +106,7 @@ Types:
* InFrame = {text | binary | ping | pong, binary()}
* Req = cowboy_req:req()
* State = any()
-* OutFrame = frame()
+* OutFrame = cow_ws:frame()
Handle the data received from the Websocket connection.
@@ -145,7 +133,7 @@ Types:
* Info = any()
* Req = cowboy_req:req()
* State = any()
-* OutFrame = frame()
+* OutFrame = cow_ws:frame()
Handle the Erlang message received.
diff --git a/doc/src/specs/rfc7230_server.ezdoc b/doc/src/specs/rfc7230_server.ezdoc
index 9ccac94..2497f56 100644
--- a/doc/src/specs/rfc7230_server.ezdoc
+++ b/doc/src/specs/rfc7230_server.ezdoc
@@ -48,7 +48,7 @@ outcome of the processing.
The time the request (request line and headers) takes to be
received by the server must be limited and subject to configuration.
A server must wait at least 5 seconds before dropping the connection.
-A 418 status code must be sent if the request line was received
+A 408 status code must be sent if the request line was received
fully when the timeout is triggered.
An HTTP/1.1 server must understand any valid HTTP/1.0 request,
@@ -105,7 +105,7 @@ forms are specific to the CONNECT and site-wide OPTIONS method,
respectively. (RFC7230 5.3.2)
The fragment part of the target URI is not sent. It must be
-ignrored by a server receiving it. (RFC7230 5.1)
+ignored by a server receiving it. (RFC7230 5.1)
```
request-target = origin-form / absolute-form / authority-form / asterisk-form
@@ -362,10 +362,6 @@ version = "HTTP/1.0" / "HTTP/1.1"
Any version number other than HTTP/1.0 or HTTP/1.1 must be
rejected by a server or intermediary with a 505 status code. (RFC7230 2.6, RFC7230 A.2)
-A request that has whitespace different than CRLF following the
-version must be rejected with a 400 status code and the closing
-of the connection. (RFC7230 3.1.1)
-
A request that has any whitespace or characters different than
CRLF following the version must be rejected with a 400 status
code and the closing of the connection. (RFC7230 3.1.1)