From 28b5bf18a3be3b933a76f8b8912c8ee55238cdc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 9 Nov 2017 12:46:23 +0000 Subject: Update documentation for Cowboy 2.1 --- docs/en/cowboy/2.0/guide/ws_handlers/index.html | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'docs/en/cowboy/2.0/guide/ws_handlers') diff --git a/docs/en/cowboy/2.0/guide/ws_handlers/index.html b/docs/en/cowboy/2.0/guide/ws_handlers/index.html index f17b1093..8e867c6f 100644 --- a/docs/en/cowboy/2.0/guide/ws_handlers/index.html +++ b/docs/en/cowboy/2.0/guide/ws_handlers/index.html @@ -7,7 +7,7 @@ - + Nine Nines: Websocket handlers @@ -122,19 +122,18 @@ be:

by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
init(Req0, State) ->
-    case cowboy_req:parse_header(<<"sec-websocket-protocol">>, Req0) of
+
init(Req, State) ->
+    case cowboy_req:parse_header(<<"sec-websocket-protocol">>, Req) of
         undefined ->
-            {cowboy_websocket, Req0, State};
+            {cowboy_websocket, Req, State};
         Subprotocols ->
             case lists:keymember(<<"mqtt">>, 1, Subprotocols) of
                 true ->
-                    Req = cowboy_req:set_resp_header(<<"sec-websocket-protocol">>,
-                        <<"mqtt">>, Req0),
-                    {cowboy_websocket, Req, State};
+                    Req2 = cowboy_req:set_resp_header(<<"sec-websocket-protocol">>,
+                        <<"mqtt">>, Req),
+                    {cowboy_websocket, Req2, State};
                 false ->
-                    Req = cowboy_req:reply(400, Req0),
-                    {ok, Req, State}
+                    {stop, Req, State}
             end
     end.
@@ -388,6 +387,8 @@ close frame will not be sent.

+
  • 2.1
  • +
  • 2.0
  • 1.0
  • -- cgit v1.2.3