Skip to content

Commit

Permalink
feat: support to use path parameter with plugin's control api (#5934)
Browse files Browse the repository at this point in the history
Co-authored-by: 罗泽轩 <[email protected]>
  • Loading branch information
The-White-Lion and spacewander authored Dec 29, 2021
1 parent eb8362c commit e9cea44
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
15 changes: 14 additions & 1 deletion apisix/control/router.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
--
local require = require
local router = require("apisix.utils.router")
local radixtree = require("resty.radixtree")
local builtin_v1_routes = require("apisix.control.v1")
local plugin_mod = require("apisix.plugin")
local core = require("apisix.core")
Expand Down Expand Up @@ -154,7 +155,19 @@ function fetch_control_api_router()
handler = empty_func,
})

return router.new(routes)
local with_parameter = false
local conf = core.config.local_conf()
if conf.apisix.enable_control and conf.apisix.control then
if conf.apisix.control.router == "radixtree_uri_with_parameter" then
with_parameter = true
end
end

if with_parameter then
return radixtree.new(routes)
else
return router.new(routes)
end
end

end -- do
Expand Down
3 changes: 3 additions & 0 deletions docs/en/latest/control-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ apisix:
port: 9090
```
The control API server does not support parameter matching by default, if you want to enable parameter matching in plugin's control API
you can add `router: 'radixtree_uri_with_parameter'` to the `control` section.

Note that the control API server should not be configured to listen to the public traffic!

## Control API Added via plugin
Expand Down
2 changes: 2 additions & 0 deletions docs/zh/latest/control-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ apisix:
port: 9090
```
插件的 control API 在默认情况下不支持参数匹配,如果想启用参数匹配功能可以在 control 部分添加 `router: 'radixtree_uri_with_parameter'`

注意: control API server 不应该被配置成监听公网地址。

## 通过插件添加的 control API
Expand Down

0 comments on commit e9cea44

Please sign in to comment.