From cf84f59d9bdf819d943b3de8e3bc85c561f88efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sat, 28 Sep 2019 15:40:41 +0200 Subject: Add persistent_term support to the router --- src/cowboy_router.erl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/cowboy_router.erl b/src/cowboy_router.erl index 44a7e18..0eb4bdd 100644 --- a/src/cowboy_router.erl +++ b/src/cowboy_router.erl @@ -160,7 +160,11 @@ compile_brackets_split(<< C, Rest/bits >>, Acc, N) -> -spec execute(Req, Env) -> {ok, Req, Env} | {stop, Req} when Req::cowboy_req:req(), Env::cowboy_middleware:env(). -execute(Req=#{host := Host, path := Path}, Env=#{dispatch := Dispatch}) -> +execute(Req=#{host := Host, path := Path}, Env=#{dispatch := Dispatch0}) -> + Dispatch = case Dispatch0 of + {persistent_term, Key} -> persistent_term:get(Key); + _ -> Dispatch0 + end, case match(Dispatch, Host, Path) of {ok, Handler, HandlerOpts, Bindings, HostInfo, PathInfo} -> {ok, Req#{ -- cgit v1.2.3