Skip to content

Commit

Permalink
local_chain: keep compatibility with current module system
Browse files Browse the repository at this point in the history
  • Loading branch information
davidor committed Nov 14, 2017
1 parent a6b047a commit 95af30e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
6 changes: 0 additions & 6 deletions apicast/src/executor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
-- when calling the policy chain methods. This 'context' contains information
-- shared among policies.

local resty_env = require('resty.env')

if resty_env.get('APICAST_MODULE') then
return require('module')
end

local policy_chain = require('policy_chain')
local policy = require('policy')
local linked_list = require('linked_list')
Expand Down
17 changes: 16 additions & 1 deletion apicast/src/policy/local_chain.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
local resty_env = require('resty.env')

local policy = require('policy')
local Proxy = require('proxy')
local _M = policy.new('Local Policy Chain')

local default_chain = require('policy_chain').build({ 'apicast' })
local function build_default_chain()
local module

if resty_env.get('APICAST_MODULE') then
-- Needed to keep compatibility with the old module system.
module = 'module'
else
module = 'apicast'
end

return require('policy_chain').build({ module })
end

local default_chain = build_default_chain()

local function find_policy_chain(context)
return context.policy_chain or (context.service and context.service.policy_chain) or default_chain
Expand Down

0 comments on commit 95af30e

Please sign in to comment.