monkeyDluffy6017 commented on code in PR #9580:
URL: https://github.com/apache/apisix/pull/9580#discussion_r1263555124
##########
apisix/admin/plugins.lua:
##########
@@ -60,16 +70,23 @@ function _M.get(name)
return 200, http_plugins
end
- if not name then
- return 400, {error_msg = "not found plugin name"}
+ local plugin
+ -- By default search through http subsystems
+ subsystem = subsystem or "http"
+
+ if subsystem == "http" then
+ plugin = plugin_get_http(name)
end
- local plugin_name = "apisix.plugins." .. name
+ if subsystem == "stream" then
+ plugin = plugin_get_stream(name)
+ end
- local ok, plugin = pcall(require, plugin_name)
- if not ok then
+ if not plugin then
+ subsystem = subsystem or "http"
+ local err = "failed to load plugin " .. name .. " in subsystem " ..
subsystem
core.log.warn("failed to load plugin [", name, "] err: ", plugin)
- return 400, {error_msg = "failed to load plugin " .. name}
+ return 400, {error_msg = err }
Review Comment:
There is no need to return an error here? If the plugin doesn't exist, it is
fine to return `nil`?
--
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]