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/30 01:30:15 UTC

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

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