mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +00:00
Add the private set_bindings/4 function used by cowboy_protocol
This commit is contained in:
parent
5b56dd780b
commit
c1dd5b5176
2 changed files with 11 additions and 3 deletions
|
@ -242,9 +242,9 @@ onrequest(Req, State=#state{onrequest=OnRequest}) ->
|
||||||
dispatch(Req, State=#state{dispatch=Dispatch,
|
dispatch(Req, State=#state{dispatch=Dispatch,
|
||||||
host_tokens=HostTokens, path_tokens=PathTokens}) ->
|
host_tokens=HostTokens, path_tokens=PathTokens}) ->
|
||||||
case cowboy_dispatcher:match(HostTokens, PathTokens, Dispatch) of
|
case cowboy_dispatcher:match(HostTokens, PathTokens, Dispatch) of
|
||||||
{ok, Handler, Opts, Binds, HostInfo, PathInfo} ->
|
{ok, Handler, Opts, Bindings, HostInfo, PathInfo} ->
|
||||||
handler_init(Req#http_req{host_info=HostInfo, path_info=PathInfo,
|
Req2 = cowboy_req:set_bindings(HostInfo, PathInfo, Bindings, Req),
|
||||||
bindings=Binds}, State#state{handler={Handler, Opts},
|
handler_init(Req2, State#state{handler={Handler, Opts},
|
||||||
host_tokens=undefined, path_tokens=undefined});
|
host_tokens=undefined, path_tokens=undefined});
|
||||||
{error, notfound, host} ->
|
{error, notfound, host} ->
|
||||||
error_terminate(400, State);
|
error_terminate(400, State);
|
||||||
|
|
|
@ -107,6 +107,7 @@
|
||||||
-export([set_connection/2]).
|
-export([set_connection/2]).
|
||||||
-export([add_header/3]).
|
-export([add_header/3]).
|
||||||
-export([set_buffer/2]).
|
-export([set_buffer/2]).
|
||||||
|
-export([set_bindings/4]).
|
||||||
|
|
||||||
%% Misc API.
|
%% Misc API.
|
||||||
-export([compact/1]).
|
-export([compact/1]).
|
||||||
|
@ -941,6 +942,13 @@ add_header(Name, Value, Req=#http_req{headers=Headers}) ->
|
||||||
set_buffer(Buffer, Req) ->
|
set_buffer(Buffer, Req) ->
|
||||||
Req#http_req{buffer=Buffer}.
|
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.
|
%% Misc API.
|
||||||
|
|
||||||
%% @doc Compact the request data by removing all non-system information.
|
%% @doc Compact the request data by removing all non-system information.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue