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/18 03:08:39 UTC

[GitHub] [apisix] tokers commented on issue #2774: request help: Advanced routing settings

tokers commented on issue #2774:
URL: https://github.com/apache/apisix/issues/2774#issuecomment-729347542


   > Hi, @aijunziaixifu, As the @spacewander answered in #2763, you can write your filter function.
   > 
   > Here, I give you an example, you can have a try.
   > 
   > ```
   > curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d '{
   >     "uri": "/index.html",
   >     "methods": ["PUT", "GET"],
   >     "upstream": {
   >         "type": "roundrobin",
   >         "nodes": {
   >             "39.97.63.215:80": 1
   >         }
   >     },
   >     "filter_func": "function(vars)
   >     local core = require (\"apisix.core\")
   >     local body, err = core.request.get_body()
   >     if not body then
   >         return false
   >     end
   > 
   >     local data, err = core.json.decode(body)
   >     if not data then
   >         return false
   >     end
   > 
   >     if data[\"a\"] == \"b\" then
   >         return true
   >     end
   > 
   >     return false
   > end"
   > }'
   > ```
   > 
   > By the way, I had seen many people have questions about this. May I add this to the document?
   
   That can be classified as one section of "Apache APISIX Best Practices".


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