Просмотр исходного кода

Handler:init/2 should also return the Request in case it changed.

Loïc Hoguin 14 лет назад
Родитель
Сommit
5e80e4baac
2 измененных файлов с 2 добавлено и 2 удалено
  1. 1 1
      README.md
  2. 1 1
      src/cowboy_http_protocol.erl

+ 1 - 1
README.md

@@ -66,7 +66,7 @@ handler could be written like this:
     -export([init/2, handle/2]).
 
     init(Req, Opts) ->
-        {ok, undefined}.
+        {ok, Req, undefined}.
 
     handle(Req, State) ->
         {reply, 200, [], "Hello World!"}.

+ 1 - 1
src/cowboy_http_protocol.erl

@@ -111,7 +111,7 @@ header(http_eoh, Req, State) ->
 -spec handler_init(Req::#http_req{}, State::#state{}) -> ok.
 handler_init(Req, State=#state{handler={Handler, Opts}}) ->
 	case Handler:init(Req, Opts) of
-		{ok, HandlerState} ->
+		{ok, Req, HandlerState} ->
 			handler_loop(HandlerState, Req, State)
 		%% @todo {mode, active}; {upgrade_protocol, Module}; {error, Reason}
 	end.