0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

make set_env working with maps.

This commit is contained in:
Alexandre Snarskii 2016-11-02 20:16:56 +03:00 committed by Loïc Hoguin
parent 78af194e07
commit 304e3efbf8
No known key found for this signature in database
GPG key ID: 71366FF21851DF03

View file

@ -72,7 +72,6 @@ stop_listener(Ref) ->
-spec set_env(ranch:ref(), atom(), any()) -> ok.
set_env(Ref, Name, Value) ->
Opts = ranch:get_protocol_options(Ref),
{_, Env} = lists:keyfind(env, 1, Opts),
Opts2 = lists:keyreplace(env, 1, Opts,
{env, lists:keystore(Name, 1, Env, {Name, Value})}),
{_, Env} = maps:find(env, Opts),
Opts2 = maps:put(env, maps:put(Name, Value, Env), Opts),
ok = ranch:set_protocol_options(Ref, Opts2).