nic-chen commented on issue #5796:
URL: https://github.com/apache/apisix/issues/5796#issuecomment-995630190
hi @tzssangglass
Do you have time to help take a look? thanks!
The script generated by the dashboard looks like this:
```lua
local core = require("apisix.core")
local plugin = require("apisix.plugin")
local tablepool = core.tablepool
local _M = {}
_M.conf_e7dff882_6ea8_4c39_b167_2ef655e4de6e = core.json.decode(
[[{"disable":false,"rules":[{"match":[{"vars":[["arg_shop","==","aa"]]}],"weighted_upstreams":[{"upstream":{"name":"upstream_A","nodes":{"uat-open-app-ads.uat.svc.cluster.local:8080":10},"type":"roundrobin"}}]}]}]]
)
local traffic_split = plugin.get("traffic-split")
local function func_rule_e7dff882_6ea8_4c39_b167_2ef655e4de6e(ctx)
local phase_fun = traffic_split.access or traffic_split.rewrite
local plugins = ctx.script_plugins
local code, body = phase_fun(_M.conf_e7dff882_6ea8_4c39_b167_2ef655e4de6e,
ctx)
core.table.insert(plugins, "traffic-split")
core.table.insert(plugins, "conf_e7dff882_6ea8_4c39_b167_2ef655e4de6e")
return _M.func_rule_84700f3e_7edc_4552_892f_62d3e72483be(ctx)
end
_M.func_rule_e7dff882_6ea8_4c39_b167_2ef655e4de6e =
func_rule_e7dff882_6ea8_4c39_b167_2ef655e4de6e
_M.conf_84700f3e_7edc_4552_892f_62d3e72483be = core.json.decode(
[[{"disable":false,"regex_uri":["^/zendesk/(.*)","/$1"],"scheme":"http"}]]
)
local proxy_rewrite = plugin.get("proxy-rewrite")
local function func_rule_84700f3e_7edc_4552_892f_62d3e72483be(ctx)
local plugins = ctx.script_plugins
local phase_fun = proxy_rewrite.access or proxy_rewrite.rewrite
if phase_fun then
local code, body =
phase_fun(_M.conf_84700f3e_7edc_4552_892f_62d3e72483be, ctx)
if code or body then
core.response.exit(code, body)
end
end
core.table.insert(plugins, "proxy-rewrite")
core.table.insert(plugins, "conf_84700f3e_7edc_4552_892f_62d3e72483be")
return
end
_M.func_rule_84700f3e_7edc_4552_892f_62d3e72483be =
func_rule_84700f3e_7edc_4552_892f_62d3e72483be
_M.access = function(ctx)
ctx.script_plugins = {}
return func_rule_e7dff882_6ea8_4c39_b167_2ef655e4de6e(ctx)
end
_M.header_filter = function(ctx)
local plugins = ctx.script_plugins
for i = 1, #plugins, 2 do
local plugin_name = plugins[i]
local plugin_conf_name = plugins[i + 1]
local plugin_obj = plugin.get(plugin_name)
local phase_fun = plugin_obj.header_filter
if phase_fun then
phase_fun(_M[plugin_conf_name], ctx)
end
end
end
_M.body_filter = function(ctx)
local plugins = ctx.script_plugins
for i = 1, #plugins, 2 do
local plugin_name = plugins[i]
local plugin_conf_name = plugins[i + 1]
local plugin_obj = plugin.get(plugin_name)
local phase_fun = plugin_obj.body_filter
if phase_fun then
phase_fun(_M[plugin_conf_name], ctx)
end
end
end
_M.log = function(ctx)
local plugins = ctx.script_plugins
for i = 1, #plugins, 2 do
local plugin_name = plugins[i]
local plugin_conf_name = plugins[i + 1]
local plugin_obj = plugin.get(plugin_name)
local phase_fun = plugin_obj.log
if phase_fun then
phase_fun(_M[plugin_conf_name], ctx)
end
end
tablepool.release("script_plugins", ctx.script_plugins)
end
return _M
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]