Closed shijunLee closed 1 year ago
Found a way, not very official though:
local radix = require "resty.radixtree"
local rx = radix.new({
{
paths = { "/name/:name/*other" },
methods = { "GET" },
metadata = "metadata /bb",
handler = function(opts)
local matched = opts.matched
ngx.say(matched.name)
ngx.say(matched.other)
end
}
})
assert(rx)
local path = string.gsub(ngx.var.uri, "?.*", "")
local opts = {
matched = {},
method = ngx.req.get_method(),
}
local ok = rx:dispatch(path, opts, opts)
if not ok then
ngx.log(ngx.ERR, "router dispath failed")
ngx.exit(ngx.HTTP_NOT_FOUND)
end
Found a way, not very official though:
local radix = require "resty.radixtree" local rx = radix.new({ { paths = { "/name/:name/*other" }, methods = { "GET" }, metadata = "metadata /bb", handler = function(opts) local matched = opts.matched ngx.say(matched.name) ngx.say(matched.other) end } }) assert(rx) local path = string.gsub(ngx.var.uri, "?.*", "") local opts = { matched = {}, method = ngx.req.get_method(), } local ok = rx:dispatch(path, opts, opts) if not ok then ngx.log(ngx.ERR, "router dispath failed") ngx.exit(ngx.HTTP_NOT_FOUND) end
yes, i current use this method get the request param,thanks
I want to get path parameters in apisix control api , the route default call dispatch method ,but can not get path param in the customer control api