You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/11/21 07:44:53 UTC

[GitHub] [apisix] Firstsawyou commented on issue #2809: [DISCUSS]: add vars matching rules to public methods

Firstsawyou commented on issue #2809:
URL: https://github.com/apache/apisix/issues/2809#issuecomment-731524200


   > > But these rules are in the apisix/deps/share/lua/5.1/resty/radixtree.lua file, not in the public method.
   > 
   > @Firstsawyou I am not get your point.
   
   What I mean is that we can't reuse the matching rules in radixtree.lua, because his definition is local.
   The matching rule definition in radixtree.lua:
   
   ```lua
   local compare_funcs = {
       ["=="] = function (l_v, r_v)
           if type(r_v) == "number" then
               l_v = tonumber(l_v)
               if not l_v then
                   return false
               end
           end
           return l_v == r_v
       end,
       ["~="] = function (l_v, r_v)
           return l_v ~= r_v
       end,
       [">"] = function (l_v, r_v)
           l_v = tonumber(l_v)
           r_v = tonumber(r_v)
           if not l_v or not r_v then
               return false
           end
           return l_v > r_v
       end,
       ["<"] = function (l_v, r_v)
           l_v = tonumber(l_v)
           r_v = tonumber(r_v)
           if not l_v or not r_v then
               return false
           end
           return l_v < r_v
       end,
       ["~~"] = function (l_v, r_v)
           local from = re_find(l_v, r_v, "jo")
           if from then
               return true
           end
           return false
       end,
       ["IN"] = in_array,
       ["in"] = in_array,
   }
   ```


----------------------------------------------------------------
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:
users@infra.apache.org