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/20 16:40:54 UTC

[GitHub] [apisix] Firstsawyou opened a new issue #2809: [DISCUSS]: add vars matching rules to public methods

Firstsawyou opened a new issue #2809:
URL: https://github.com/apache/apisix/issues/2809


   ### Issue description
   
   We all know that apisix supports vars matching rules, similar to this: {var, operator, val}. But these rules are in the `apisix/deps/share/lua/5.1/resty/radixtree.lua` file, not in the public method. Therefore, we cannot reuse these rules. The `match` rule is a very useful feature. If we add the `match` rule to the `apisix/apisix/core` module, I think it must be very interesting.
   
   Examples of vars matching:
   
   ```
   [ "arg_name", "==", "rose" ],
   [ "http_appKey", "~~", "[a-z].+" ]
   [ "server_port", ">=", "80" ]
   ```
   
   Supported operators: `==, ~=, ~~, >, >=, <, <=, ip, ip_in`
   
   ### Operator list
   
   | Operator  | Description           |         Example             |
   |-----------|-----------------------|-----------------------------|
   | ==        | equal                 | {"arg_name", "==", "json"}  |
   | ~=        | not equal to          | {"arg_name", "~=", "json"}  |
   | ~~        | Regular match         | {"arg_name", "~~", "[a-z]+"}|
   | <         | Less than             | {"arg_age", "<", 24}        |
   | <=        | Less than or equal to | {"arg_age", "<=", 24}       |
   | >         | more than the         | {"arg_age", ">", 24}        |
   | >=        | greater or equal to   | {"arg_age", ">=", 24}       |
   
   what do you think? Welcome to discuss together.
   


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
starsz commented on issue #2809:
URL: https://github.com/apache/apisix/issues/2809#issuecomment-731487613


   Where can these matching rules be used?Can you give some examples?


----------------------------------------------------------------
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



[GitHub] [apisix] spacewander closed issue #2809: [DISCUSS]: add vars matching rules to public methods

Posted by GitBox <gi...@apache.org>.
spacewander closed issue #2809:
URL: https://github.com/apache/apisix/issues/2809


   


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #2809:
URL: https://github.com/apache/apisix/issues/2809#issuecomment-737990322


   Done


----------------------------------------------------------------
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



[GitHub] [apisix] starsz edited a comment on issue #2809: [DISCUSS]: add vars matching rules to public methods

Posted by GitBox <gi...@apache.org>.
starsz edited a comment on issue #2809:
URL: https://github.com/apache/apisix/issues/2809#issuecomment-731487613


   Hi, Where can these matching rules be used?Can you give some examples?


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
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



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

Posted by GitBox <gi...@apache.org>.
moonming commented on issue #2809:
URL: https://github.com/apache/apisix/issues/2809#issuecomment-731506793


   > Maybe we can move the matching rules to a separate repo, so that we can also use this to satisfy [api7/lua-resty-radixtree#74](https://github.com/api7/lua-resty-radixtree/issues/74)
   
   agreed, router already support match rules.


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #2809:
URL: https://github.com/apache/apisix/issues/2809#issuecomment-735244226


   > Maybe we can move the matching rules to a separate repo, so that we can also use this to satisfy [api7/lua-resty-radixtree#74](https://github.com/api7/lua-resty-radixtree/issues/74)
   
   agree +1


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on issue #2809:
URL: https://github.com/apache/apisix/issues/2809#issuecomment-731524773


   > Hi, Where can these matching rules be used?Can you give some examples?
   
   This is a related issue that needs to use these rules:
   https://github.com/apache/apisix/issues/2511 
   https://github.com/apache/apisix/issues/2303
   


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
moonming commented on issue #2809:
URL: https://github.com/apache/apisix/issues/2809#issuecomment-731506870


   > 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. 


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #2809:
URL: https://github.com/apache/apisix/issues/2809#issuecomment-731492268


   Maybe we can move the matching rules to a separate repo, so that we can also use this to satisfy https://github.com/api7/lua-resty-radixtree/issues/74 


----------------------------------------------------------------
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