Skip to content

Commit

Permalink
policy/local_chain: return the chain in build_chain()
Browse files Browse the repository at this point in the history
Makes the code a bit more readable.
  • Loading branch information
davidor committed Apr 23, 2018
1 parent 21dba56 commit 85a14f2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions gateway/src/apicast/policy/local_chain/local_chain.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ local function build_chain(context)
local proxy = Proxy.new(context.configuration)

context.proxy = context.proxy or proxy
context.policy_chain = find_policy_chain(context)

local policy_chain = find_policy_chain(context)
context.policy_chain = policy_chain

return policy_chain
end

-- forward all policy methods to the policy chain
Expand All @@ -45,9 +49,9 @@ end
local rewrite = _M.rewrite

function _M:rewrite(context, ...)
build_chain(context)
local policy_chain = build_chain(context)

context = LinkedList.readwrite(context, find_policy_chain(context):export())
context = LinkedList.readwrite(context, policy_chain:export())

rewrite(self, context, ...)
end
Expand Down

0 comments on commit 85a14f2

Please sign in to comment.