shreemaan-abhishek commented on issue #9718:
URL: https://github.com/apache/apisix/issues/9718#issuecomment-1606056169

   Translation:
   
   ### help request: How to modify request body in apisix pre-plugin 
(ext-plugin-pre-req)? Ask the technical teacher to help me, thank you!
   
   The ext-plugin-pre-req plug-in is enabled in the apisix routing 
configuration, how to modify the request body in the plug-in filter method?
   The routing configuration information is as follows:
   
   ```json
   {
     "uri": "/test-api/*",
     "name": "测试api",
     "desc": "测试api",
     "methods": [
       "GET",
       "POST"
     ],
     "plugins": {
       "ext-plugin-pre-req": {
         "allow_degradation": false,
         "conf": [
           {
             "name": "AuthFilter",
             "value": "authFilter"
           }
         ],
         "disable": false
       }
     },
     "service_id": "1669247957284687873",
     "labels": {
       "API_VERSION": "v1"
     },
     "status": 1
   }
   ```
   The plug-in execution code is as follows:
   
   ```java
   @component
   public class AuthFilter implements PluginFilter {
   private final Logger logger = LoggerFactory. getLogger(AuthFilter. class);
   
   @Override
   public String name() {
        return "AuthFilter";
   }
   
   @Override
   public void filter(HttpRequest request, HttpResponse response, 
PluginFilterChain chain) {
        logger.info("【Enter pre-intercept filter】");
        logger.info("【Acquired request parameters】" + request.getBody());
   
        // How to modify the request parameters here, and reset the request 
parameters to the upstream service
   
        chain. filter(request, response);
   }
   
   @Override
   public void postFilter(PostRequest request, PostResponse response, 
PluginFilterChain chain) {
        logger.info("【Enter post-interception filter】");
        chain. postFilter(request, response);
   }
   
   @Override
   public List<String> requiredVars() {
        List<String> vars = new ArrayList<>();
        vars.add("request_id");
        return vars;
   }
   
   @Override
   public Boolean requiredBody() {
        return true;
   }
   
   @Override
   public Boolean requiredRespBody() {
        return true;
   }
   ```
   
   Please help me, technical teachers, thank you!
   


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