aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2024-01-05 12:31:48 +0100
committerLoïc Hoguin <[email protected]>2024-01-05 12:31:48 +0100
commit67df6fedaea83b8159fbadbadf460a1f3dd98c51 (patch)
treef11dcbe26eef3b59a94cad463761bc42266659cd /src/cowboy.erl
parent8f49f8792ac5993b46dafcc04d87fb62056c9a80 (diff)
downloadcowboy-67df6fedaea83b8159fbadbadf460a1f3dd98c51.tar.gz
cowboy-67df6fedaea83b8159fbadbadf460a1f3dd98c51.tar.bz2
cowboy-67df6fedaea83b8159fbadbadf460a1f3dd98c51.zip
Add cowboy:get_env/2,3
Diffstat (limited to 'src/cowboy.erl')
-rw-r--r--src/cowboy.erl14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/cowboy.erl b/src/cowboy.erl
index bd81cf3..21d7f59 100644
--- a/src/cowboy.erl
+++ b/src/cowboy.erl
@@ -17,6 +17,8 @@
-export([start_clear/3]).
-export([start_tls/3]).
-export([stop_listener/1]).
+-export([get_env/2]).
+-export([get_env/3]).
-export([set_env/3]).
%% Internal.
@@ -69,6 +71,18 @@ ensure_connection_type(TransOpts) ->
stop_listener(Ref) ->
ranch:stop_listener(Ref).
+-spec get_env(ranch:ref(), atom()) -> ok.
+get_env(Ref, Name) ->
+ Opts = ranch:get_protocol_options(Ref),
+ Env = maps:get(env, Opts, #{}),
+ maps:get(Name, Env).
+
+-spec get_env(ranch:ref(), atom(), any()) -> ok.
+get_env(Ref, Name, Default) ->
+ Opts = ranch:get_protocol_options(Ref),
+ Env = maps:get(env, Opts, #{}),
+ maps:get(Name, Env, Default).
+
-spec set_env(ranch:ref(), atom(), any()) -> ok.
set_env(Ref, Name, Value) ->
Opts = ranch:get_protocol_options(Ref),