aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rw-r--r--src/cowboy_http_protocol.erl5
2 files changed, 5 insertions, 4 deletions
diff --git a/README.md b/README.md
index ff82d2f..c47974c 100644
--- a/README.md
+++ b/README.md
@@ -63,9 +63,9 @@ use one of the predefined handlers or write your own. An hello world HTTP
handler could be written like this:
-module(my_handler).
- -export([init/2, handle/2, terminate/2]).
+ -export([init/3, handle/2, terminate/2]).
- init(Req, Opts) ->
+ init({tcp, http}, Req, Opts) ->
{ok, Req, undefined}.
handle(Req, State) ->
diff --git a/src/cowboy_http_protocol.erl b/src/cowboy_http_protocol.erl
index 9bb22c3..d950373 100644
--- a/src/cowboy_http_protocol.erl
+++ b/src/cowboy_http_protocol.erl
@@ -130,8 +130,9 @@ header(http_eoh, Req, State) ->
handler_init(Req, State).
-spec handler_init(Req::#http_req{}, State::#state{}) -> ok.
-handler_init(Req, State=#state{handler={Handler, Opts}}) ->
- case catch Handler:init(Req, Opts) of
+handler_init(Req, State=#state{
+ transport=Transport, handler={Handler, Opts}}) ->
+ case catch Handler:init({Transport:name(), http}, Req, Opts) of
{ok, Req, HandlerState} ->
handler_loop(HandlerState, Req, State);
%% @todo {upgrade, transport, Module}; {upgrade, protocol, Module}