tzssangglass commented on issue #1574:
URL: https://github.com/apache/apisix/issues/1574#issuecomment-711287916
Under the condition of setting `uris` or `hosts`, I want to record the
specific elements in the `uris` or `hosts` that match the current request.
At first I tried to take advantage of the pass by reference feature of the
table, so I wrote the following code
```
handler = function (api_ctx, curr_req_matched_record)
api_ctx.matched_params = nil
api_ctx.matched_route = route
--to keep the record which matches the current request and pass it
to api_ctx
api_ctx.curr_req_matched_record = curr_req_matched_record
end
```
```
local curr_req_matched_record = {}
match_opts.matched = curr_req_matched_record
local ok = uri_router:dispatch(api_ctx.var.uri, match_opts, api_ctx,
curr_req_matched_record)
```
I want to init `match_opts.matched` , so that I can get the matched record
on the callback after dispatch success.
But this can lead to failure in some cases, because of the following code
(https://github.com/api7/lua-resty-radixtree/blob/master/lib/resty/radixtree.lua#L456-L458),
```
if not opts.matched and not route.param then
return true
end
```
In my case it won't return true.
So this line of thinking tends to be invalid.
I also considered the `metadata` you mentioned above, but that doesn't solve
`uris` or `hosts`.
Now I don't have a solution, is there a way to get the specific elements in
the `uris` or `hosts` that match the current request in `apisix`?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]