wilsonGen opened a new pull request, #11289:
URL: https://github.com/apache/apisix/pull/11289

   ### Description
   
   <!-- Please include a summary of the change and which issue is fixed. -->
   After this change, the traffic-split will be able to support rules based on 
json body in POST request.                                                      
                                      For example: 
   If we create a route like this:
   ```json
   {
      "methods": [
         "POST"
      ],
      "name": "Route based on json body (POST)",
      "uri": "/*",
      "plugins": {
         "traffic-split": {
            "rules": [
               {
                  "match": [
                     {
                        "vars": [
                           [
                              "json_body_arg_cat.sounds_like",
                              "==",
                              "meow"
                           ]
                        ]
                     }
                  ],
                  "weighted_upstreams": [
                     {
                        "upstream": {
                           "nodes": {
                              "httpbin.org:80": 1
                           },
                           "type": "roundrobin"
                        },
                        "weight": 3
                     }
                  ]
               }
            ]
         }
      },
      "upstream": {
         "nodes": {
            "google.com": 1
         },
         "type": "roundrobin"
      }
   }
   ```
   In traffic-split we defined "json_body_arg_cat.sounds_like" == "mewo", which 
means it will match the json body like this:
   `
   {
       "cat": {
           "sounds_like": "meow"
       },
       "other_fields": "hihi"
   }
   `
   <!-- Please also include relevant motivation and context. -->
   Motivation:
   Currently the traffic-split plugin can create rules based on the default 
form of the POST request.
   However it does not support rules based on application/json in the POST 
request body.
   I think it will be great if it can support the rules based on json body as 
well.
   As I have the need to have rules based on json body too.
   Fixes # (issue)
   
   ### Checklist
   
   - [ v] I have explained the need for this PR and the problem it solves
   - [ v] I have explained the changes or the new features added to this PR
   - [ ] I have added tests corresponding to this change
   - [ ] I have updated the documentation to reflect this change
   - [v ] I have verified that this change is backward compatible (If not, 
please discuss on the [APISIX mailing 
list](https://github.com/apache/apisix/tree/master#community) first)
   
   <!--
   
   Note
   
   1. Mark the PR as draft until it's ready to be reviewed.
   2. Always add/update tests for any changes unless you have a good reason.
   3. Always update the documentation to reflect the changes made in the PR.
   4. Make a new commit to resolve conversations instead of `push -f`.
   5. To resolve merge conflicts, merge master instead of rebasing.
   6. Use "request review" to notify the reviewer after making changes.
   7. Only a reviewer can mark a conversation as resolved.
   
   -->
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to