From 9317751cb314328340fede4cb780562b77afe8c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 2 Oct 2017 16:19:13 +0200 Subject: Fix cowboy:set_env when the env value is missing --- src/cowboy.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/cowboy.erl b/src/cowboy.erl index f01bcf4..99615de 100644 --- a/src/cowboy.erl +++ b/src/cowboy.erl @@ -68,6 +68,6 @@ stop_listener(Ref) -> -spec set_env(ranch:ref(), atom(), any()) -> ok. set_env(Ref, Name, Value) -> Opts = ranch:get_protocol_options(Ref), - {_, Env} = maps:find(env, Opts), + Env = maps:get(env, Opts, #{}), Opts2 = maps:put(env, maps:put(Name, Value, Env), Opts), ok = ranch:set_protocol_options(Ref, Opts2). -- cgit v1.2.3