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 2021/11/29 06:26:25 UTC

[GitHub] [apisix] starsz opened a new issue #5634: request help: support get the key from function in limit-* plugins

starsz opened a new issue #5634:
URL: https://github.com/apache/apisix/issues/5634


   ### Issue description
   
   Hi, 
   Now, I see we had support `var`, `var_combination` in apisix limit-* plugins yet.
   I think we can support a type like `function` so that we can write some logic as a function in the key.
   Then we can get the key by the function.
   
   
   
   ### Environment
   
   - apisix version (cmd: `apisix version`): 2.10.2
   - OS (cmd: `uname -a`):
   - OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`):
   - etcd version, if have (cmd: run `curl http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):
   - apisix-dashboard version, if have:
   - the plugin runner version, if the issue is about a plugin runner (cmd: depended on the kind of runner):
   - luarocks version, if the issue is about installation (cmd: `luarocks --version`):
   


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

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander commented on issue #5634: request help: support get the key from function in limit-* plugins

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


   What about allowing user to register their var in https://github.com/apache/apisix/blob/8f0b066c86257ad6af19f9b3b7e209ece95d17c9/apisix/core/ctx.lua#L147?


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

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander commented on issue #5634: request help: support get the key from function in limit-* plugins

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


   We can register the variable with a custom function, like:
   ```
   core.ctx.register_var("my_consumer", function (...)
   end)
   ```


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

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander closed issue #5634: request help: support get the key from function in limit-* plugins

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


   


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

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] starsz edited a comment on issue #5634: request help: support get the key from function in limit-* plugins

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


   > We can register the variable with a custom function, like:
   > 
   > ```
   > core.ctx.register_var("my_consumer", function (...)
   > end)
   > ```
   
   Oh, that's good. Wait for the new feature.


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

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] starsz commented on issue #5634: request help: support get the key from function in limit-* plugins

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


   > What about allowing user to register their var in
   > 
   > https://github.com/apache/apisix/blob/8f0b066c86257ad6af19f9b3b7e209ece95d17c9/apisix/core/ctx.lua#L147
   > 
   > ?
   
   I think support function would be more flexible. 
   We can write the function like this: 
   ```
   function generate_key(ctx)
     if ctx.var.http_x_consumer == "a" then
          return "a"
     end
   
     return "default"
   end
   ```
   
   Then we can limit the specific request with a special header.


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

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] starsz commented on issue #5634: request help: support get the key from function in limit-* plugins

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


   > We can register the variable with a custom function, like:
   > 
   > ```
   > core.ctx.register_var("my_consumer", function (...)
   > end)
   > ```
   
   Oh, that's good.


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

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org