monkeyDluffy6017 commented on code in PR #9580:
URL: https://github.com/apache/apisix/pull/9580#discussion_r1263562092
##########
apisix/admin/plugins.lua:
##########
@@ -85,16 +102,37 @@ function _M.get(name)
end
-function _M.get_plugins_list()
- local plugins = core.config.local_conf().plugins
+function _M.get_plugins_list(subsystem)
+ local http_plugins
+ local stream_plugins
+ if subsystem == "stream" then
+ stream_plugins = core.config.local_conf().stream_plugins
+ end
+ if subsystem == "http" then
+ http_plugins = core.config.local_conf().plugins
+ end
+
local priorities = {}
local success = {}
- for i, name in ipairs(plugins) do
- local plugin_name = "apisix.plugins." .. name
- local ok, plugin = pcall(require, plugin_name)
- if ok and plugin.priority then
- priorities[name] = plugin.priority
- table_insert(success, name)
+ if http_plugins then
+ for i, name in ipairs(http_plugins) do
+ local plugin_name = "apisix.plugins." .. name
+ local ok, plugin = pcall(require, plugin_name)
+ if ok and plugin.priority then
+ priorities[name] = plugin.priority
Review Comment:
can these two function be used here?
```
local plugin_get_http = require("apisix.plugin").get
local plugin_get_stream = require("apisix.plugin").get_stream
```
##########
apisix/admin/plugins.lua:
##########
@@ -85,16 +102,37 @@ function _M.get(name)
end
-function _M.get_plugins_list()
- local plugins = core.config.local_conf().plugins
+function _M.get_plugins_list(subsystem)
+ local http_plugins
+ local stream_plugins
+ if subsystem == "stream" then
+ stream_plugins = core.config.local_conf().stream_plugins
+ end
+ if subsystem == "http" then
+ http_plugins = core.config.local_conf().plugins
+ end
+
local priorities = {}
local success = {}
- for i, name in ipairs(plugins) do
- local plugin_name = "apisix.plugins." .. name
- local ok, plugin = pcall(require, plugin_name)
- if ok and plugin.priority then
- priorities[name] = plugin.priority
- table_insert(success, name)
+ if http_plugins then
+ for i, name in ipairs(http_plugins) do
+ local plugin_name = "apisix.plugins." .. name
+ local ok, plugin = pcall(require, plugin_name)
+ if ok and plugin.priority then
+ priorities[name] = plugin.priority
+ table_insert(success, name)
+ end
+ end
+ end
+
+ if stream_plugins then
+ for i, name in ipairs(stream_plugins) do
+ local plugin_name = "apisix.stream.plugins." .. name
+ local ok, plugin = pcall(require, plugin_name)
+ if ok and plugin.priority then
+ priorities[name] = plugin.priority
+ table_insert(success, name)
Review Comment:
ditto
--
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]