diff options
author | Loïc Hoguin <[email protected]> | 2012-09-17 00:39:29 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2012-09-17 13:57:28 +0200 |
commit | c1dd5b5176813d048654c66550a434ef30f96908 (patch) | |
tree | 4ce169c0c279968513dad71e2c40531b7dd721f5 /src | |
parent | 5b56dd780bfeddac96ae8360bd5b352e427e1b3d (diff) | |
download | cowboy-c1dd5b5176813d048654c66550a434ef30f96908.tar.gz cowboy-c1dd5b5176813d048654c66550a434ef30f96908.tar.bz2 cowboy-c1dd5b5176813d048654c66550a434ef30f96908.zip |
Add the private set_bindings/4 function used by cowboy_protocol
Diffstat (limited to 'src')
-rw-r--r-- | src/cowboy_protocol.erl | 6 | ||||
-rw-r--r-- | src/cowboy_req.erl | 8 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/cowboy_protocol.erl b/src/cowboy_protocol.erl index bcbdf57..9042117 100644 --- a/src/cowboy_protocol.erl +++ b/src/cowboy_protocol.erl @@ -242,9 +242,9 @@ onrequest(Req, State=#state{onrequest=OnRequest}) -> dispatch(Req, State=#state{dispatch=Dispatch, host_tokens=HostTokens, path_tokens=PathTokens}) -> case cowboy_dispatcher:match(HostTokens, PathTokens, Dispatch) of - {ok, Handler, Opts, Binds, HostInfo, PathInfo} -> - handler_init(Req#http_req{host_info=HostInfo, path_info=PathInfo, - bindings=Binds}, State#state{handler={Handler, Opts}, + {ok, Handler, Opts, Bindings, HostInfo, PathInfo} -> + Req2 = cowboy_req:set_bindings(HostInfo, PathInfo, Bindings, Req), + handler_init(Req2, State#state{handler={Handler, Opts}, host_tokens=undefined, path_tokens=undefined}); {error, notfound, host} -> error_terminate(400, State); diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl index aad6a97..acee88b 100644 --- a/src/cowboy_req.erl +++ b/src/cowboy_req.erl @@ -107,6 +107,7 @@ -export([set_connection/2]). -export([add_header/3]). -export([set_buffer/2]). +-export([set_bindings/4]). %% Misc API. -export([compact/1]). @@ -941,6 +942,13 @@ add_header(Name, Value, Req=#http_req{headers=Headers}) -> set_buffer(Buffer, Req) -> Req#http_req{buffer=Buffer}. +%% @private +-spec set_bindings(cowboy_dispatcher:tokens(), cowboy_dispatcher:tokens(), + cowboy_dispatcher:bindings(), Req) -> Req when Req::req(). +set_bindings(HostInfo, PathInfo, Bindings, Req) -> + Req#http_req{host_info=HostInfo, path_info=PathInfo, + bindings=Bindings}. + %% Misc API. %% @doc Compact the request data by removing all non-system information. |