mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +00:00
Add persistent_term support to the router
This commit is contained in:
parent
7bccad4d21
commit
cf84f59d9b
5 changed files with 80 additions and 3 deletions
|
@ -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#{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue