mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-03 20:47:35 +08:00
fix: set conf info when global rule is hit without matched rule (#3332)
Fix #3330 Signed-off-by: spacewander <spacewanderlzx@gmail.com>
This commit is contained in:
parent
746345aab2
commit
b78c87a158
@ -610,14 +610,26 @@ local function common_phase(phase_name)
|
||||
end
|
||||
|
||||
if api_ctx.global_rules then
|
||||
local orig_conf_type = api_ctx.conf_type
|
||||
local orig_conf_version = api_ctx.conf_version
|
||||
local orig_conf_id = api_ctx.conf_id
|
||||
|
||||
local plugins = core.tablepool.fetch("plugins", 32, 0)
|
||||
local values = api_ctx.global_rules.values
|
||||
for _, global_rule in config_util.iterate_values(values) do
|
||||
api_ctx.conf_type = "global_rule"
|
||||
api_ctx.conf_version = global_rule.modifiedIndex
|
||||
api_ctx.conf_id = global_rule.value.id
|
||||
|
||||
core.table.clear(plugins)
|
||||
plugins = plugin.filter(global_rule, plugins)
|
||||
run_plugin(phase_name, plugins, api_ctx)
|
||||
end
|
||||
core.tablepool.release("plugins", plugins)
|
||||
|
||||
api_ctx.conf_type = orig_conf_type
|
||||
api_ctx.conf_version = orig_conf_version
|
||||
api_ctx.conf_id = orig_conf_id
|
||||
end
|
||||
|
||||
if api_ctx.script_obj then
|
||||
|
@ -112,3 +112,18 @@ global_rules:
|
||||
- /h*
|
||||
#END
|
||||
--- error_code: 403
|
||||
|
||||
|
||||
|
||||
=== TEST 4: common phase without matched route
|
||||
--- apisix_yaml
|
||||
global_rules:
|
||||
-
|
||||
id: 1
|
||||
plugins:
|
||||
cors:
|
||||
allow_origins: "a.com,b.com"
|
||||
#END
|
||||
--- request
|
||||
GET /apisix/prometheus/metrics
|
||||
--- error_code: 200
|
||||
|
Loading…
Reference in New Issue
Block a user