mirror of
https://gitee.com/iresty/apisix.git
synced 2024-11-30 02:57:49 +08:00
refactor: don't force plugin to use /vn prefix (#3081)
This commit is contained in:
parent
31b49ad0e1
commit
7c158b739a
@ -27,7 +27,6 @@ local get_method = ngx.req.get_method
|
||||
|
||||
|
||||
local _M = {}
|
||||
local current_version = 1
|
||||
|
||||
|
||||
local fetch_control_api_router
|
||||
@ -57,24 +56,24 @@ do
|
||||
local function empty_func() end
|
||||
|
||||
function fetch_control_api_router()
|
||||
core.table.clear(v1_routes)
|
||||
|
||||
register_api_routes(v1_routes, builtin_v1_routes)
|
||||
core.table.clear(routes)
|
||||
|
||||
for _, plugin in ipairs(plugin_mod.plugins) do
|
||||
local api_fun = plugin.control_api
|
||||
if api_fun then
|
||||
local api_routes = api_fun(current_version)
|
||||
register_api_routes(v1_routes, api_routes)
|
||||
local api_route = api_fun()
|
||||
register_api_routes(routes, api_route)
|
||||
end
|
||||
end
|
||||
|
||||
core.table.clear(v1_routes)
|
||||
register_api_routes(v1_routes, builtin_v1_routes)
|
||||
|
||||
local v1_router, err = router.new(v1_routes)
|
||||
if not v1_router then
|
||||
return nil, err
|
||||
end
|
||||
|
||||
core.table.clear(routes)
|
||||
core.table.insert(routes, {
|
||||
paths = {"/v1/*"},
|
||||
filter_fun = function(vars, opts, ...)
|
||||
|
@ -18,7 +18,6 @@ local _M = {}
|
||||
|
||||
|
||||
function _M.schema()
|
||||
-- stub for test yet, fill it in the next PR
|
||||
return 200, {}
|
||||
end
|
||||
|
||||
|
@ -120,17 +120,14 @@ local function hello()
|
||||
end
|
||||
|
||||
|
||||
function _M.control_api(ver)
|
||||
if ver == 1 then
|
||||
return {
|
||||
-- /v1/plugin/example-plugin/hello
|
||||
{
|
||||
methods = {"GET"},
|
||||
uris = {"/plugin/example-plugin/hello"},
|
||||
handler = hello,
|
||||
}
|
||||
function _M.control_api()
|
||||
return {
|
||||
{
|
||||
methods = {"GET"},
|
||||
uris = {"/v1/plugin/example-plugin/hello"},
|
||||
handler = hello,
|
||||
}
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user