mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-16 05:00:24 +00:00
Add cowboy:set_env/3
This commit is contained in:
parent
76b5cfea3f
commit
b2ffff9bec
5 changed files with 63 additions and 4 deletions
|
@ -61,6 +61,7 @@
|
|||
-export([rest_patch/1]).
|
||||
-export([rest_resource_etags/1]).
|
||||
-export([rest_resource_etags_if_none_match/1]).
|
||||
-export([set_env_dispatch/1]).
|
||||
-export([set_resp_body/1]).
|
||||
-export([set_resp_header/1]).
|
||||
-export([set_resp_overwrite/1]).
|
||||
|
@ -90,7 +91,8 @@ all() ->
|
|||
{group, https_compress},
|
||||
{group, onrequest},
|
||||
{group, onresponse},
|
||||
{group, onresponse_capitalize}
|
||||
{group, onresponse_capitalize},
|
||||
{group, set_env}
|
||||
].
|
||||
|
||||
groups() ->
|
||||
|
@ -159,6 +161,9 @@ groups() ->
|
|||
]},
|
||||
{onresponse_capitalize, [], [
|
||||
onresponse_capitalize
|
||||
]},
|
||||
{set_env, [], [
|
||||
set_env_dispatch
|
||||
]}
|
||||
].
|
||||
|
||||
|
@ -272,6 +277,17 @@ init_per_group(onresponse_capitalize, Config) ->
|
|||
{timeout, 500}
|
||||
]),
|
||||
{ok, Client} = cowboy_client:init([]),
|
||||
[{scheme, <<"http">>}, {port, Port}, {opts, []},
|
||||
{transport, Transport}, {client, Client}|Config];
|
||||
init_per_group(set_env, Config) ->
|
||||
Port = 33087,
|
||||
Transport = ranch_tcp,
|
||||
{ok, _} = cowboy:start_http(set_env, 100, [{port, Port}], [
|
||||
{env, [{dispatch, []}]},
|
||||
{max_keepalive, 50},
|
||||
{timeout, 500}
|
||||
]),
|
||||
{ok, Client} = cowboy_client:init([]),
|
||||
[{scheme, <<"http">>}, {port, Port}, {opts, []},
|
||||
{transport, Transport}, {client, Client}|Config].
|
||||
|
||||
|
@ -923,6 +939,17 @@ rest_resource_etags_if_none_match(Config) ->
|
|||
{Ret, Type}
|
||||
end || {Status, ETag, Type} <- Tests].
|
||||
|
||||
set_env_dispatch(Config) ->
|
||||
Client = ?config(client, Config),
|
||||
{ok, Client2} = cowboy_client:request(<<"GET">>,
|
||||
build_url("/", Config), Client),
|
||||
{ok, 400, _, _} = cowboy_client:response(Client2),
|
||||
ok = cowboy:set_env(set_env, dispatch,
|
||||
cowboy_router:compile([{'_', [{"/", http_handler, []}]}])),
|
||||
{ok, Client3} = cowboy_client:request(<<"GET">>,
|
||||
build_url("/", Config), Client),
|
||||
{ok, 200, _, _} = cowboy_client:response(Client3).
|
||||
|
||||
set_resp_body(Config) ->
|
||||
Client = ?config(client, Config),
|
||||
{ok, Client2} = cowboy_client:request(<<"GET">>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue