mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Adds function get_env
This commit is contained in:
parent
30ee75cea1
commit
45facf44a2
1 changed files with 7 additions and 1 deletions
|
@ -17,7 +17,7 @@
|
|||
-export([start_clear/3]).
|
||||
-export([start_tls/3]).
|
||||
-export([stop_listener/1]).
|
||||
-export([set_env/3]).
|
||||
-export([set_env/3, get_env/2]).
|
||||
|
||||
%% Internal.
|
||||
-export([log/2]).
|
||||
|
@ -77,6 +77,12 @@ set_env(Ref, Name, Value) ->
|
|||
Opts2 = maps:put(env, maps:put(Name, Value, Env), Opts),
|
||||
ok = ranch:set_protocol_options(Ref, Opts2).
|
||||
|
||||
-spec get_env(Ref :: ranch:ref(), Name :: atom()) -> Value :: any().
|
||||
get_env(Ref, Name) ->
|
||||
Opts = ranch:get_protocol_options(Ref),
|
||||
Env = maps:get(env, Opts, #{}),
|
||||
maps:get(Name, Env).
|
||||
|
||||
%% Internal.
|
||||
|
||||
-spec log({log, logger:level(), io:format(), list()}, opts()) -> ok.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue