tzssangglass commented on issue #1574: URL: https://github.com/apache/apisix/issues/1574#issuecomment-711780364
I saw the example above, init `match_opts.matched` is probably the right way to think about it, as https://github.com/api7/lua-resty-radixtree#synopsis, I did. ``` match_opts.method = api_ctx.var.request_method match_opts.host = api_ctx.var.host match_opts.remote_addr = api_ctx.var.remote_addr match_opts.vars = api_ctx.var match_opts.matched = {} local ok = uri_router:dispatch(api_ctx.var.uri, match_opts, api_ctx) ``` But in this test case https://github.com/apache/apisix/blob/71dcf367d39225c2bca9a2221611e0a8cfa35eca/t/node/sanity-radixtree.t#L127-L133 It will cause the test to fail. The reason is the following code: ``` if match_route_opts(route, opts, args) then -- log_info("matched route: ", require("cjson").encode(route)) -- log_info("matched path: ", path) if compare_param(path, route, opts) then if opts_matched_exists then opts.matched._path = route.path_org end return route end end ``` https://github.com/api7/lua-resty-radixtree/blob/6b5d65eb9853c91b1d23cc4cea8941be74bb5f20/lib/resty/radixtree.lua#L663-L666 ### case 1: did't init `match_opts.matched` The test case will success, because `not opts.matched and not route.param` = `true` . The logic goes as follows  ### case 2: init `match_opts.matched` The test case will fail, because `not opts.matched and not route.param` = `false`, then execute the following code in the function `compare_param` . The logic goes as follows  So in this test case, init `matched` will cause a 404, is this to use `matched` and `metedate` in combination? But I understand that `matched` should always work, and `metedate` is used to tag the url pass of the restful api. ---------------------------------------------------------------- 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]
