lua-resty-radixtree icon indicating copy to clipboard operation
lua-resty-radixtree copied to clipboard

fix: error occurs if the opt.vars is not passed

Open xuruidong opened this issue 10 months ago • 0 comments

content_by_lua_block {
            local opts = {host = "127.0.0.1"}
            local radix = require("resty.radixtree")
            local rx = radix.new({
                {
                    paths = {"/aa*"},
                    hosts = "127.0.0.1:9080",
                    handler = function (ctx)
                        ngx.say("pass")
                    end
                }
            })
            ngx.say(rx:dispatch("/aa", opts))
        }

error log:

 "2024/04/08 13:12:50 [error] 9216#9216: *1 lua entry thread aborted: runtime error: ...ty-radixtree/lua-resty-radixtree/lib/resty/radixtree.lua:752: attempt to index field 'vars' (a nil value)" (req 0)
# stack traceback:
# coroutine 0:
# 	...ty-radixtree/lua-resty-radixtree/lib/resty/radixtree.lua: in function 'match_route_opts'
# 	...ty-radixtree/lua-resty-radixtree/lib/resty/radixtree.lua:812: in function '_match_from_routes'
# 	...ty-radixtree/lua-resty-radixtree/lib/resty/radixtree.lua:861: in function 'match_route'
# 	...ty-radixtree/lua-resty-radixtree/lib/resty/radixtree.lua:1000: in function 'dispatch'

xuruidong avatar Apr 08 '24 14:04 xuruidong