yunmaoQu commented on issue #5682:
URL: https://github.com/apache/shenyu/issues/5682#issuecomment-2422836357

   # Can i do this requirement 
   ## Implementation Steps:
   1.Modify the Data Model of the Divide Plugin: In the handler class of the 
Divide plugin, add configuration fields related to path rewriting.
   2.Modify the Processing Logic of the Divide Plugin: During the request 
processing, perform path rewriting first, and then execute service discovery 
and routing.
   3.Modify the Frontend Interface of ShenYu Admin: In the rule configuration 
of the Divide plugin, add path rewrite configuration options for users to input.
   ## **Considerations**
   
   1. **Compatibility and Default Values:**
   
      - Ensure that when users do not provide path rewrite configurations, the 
Divide plugin continues to work as per the original logic.
      - In the code, add checks so that path rewriting is performed only when 
the configuration fields are not empty.
   
   2. **Configuration Validation:**
   
      - In the frontend form, add basic validation for regular expressions to 
prompt users to enter the correct format.
   
   3. **Performance Impact:**
   
      - Since the path rewrite processing is added, pay attention to the impact 
on request processing performance. You can evaluate this through performance 
testing.
   
   4. **Logging:**
   
      - Add logs before and after path rewriting to facilitate debugging and 
issue troubleshooting.
   
        ```java
        if (matcher.find()) {
            String newPath = 
matcher.replaceAll(ruleHandle.getPathRewriteReplacement());
            LOG.info("Path rewritten from {} to {}", originalPath, newPath);
            // ...
        }
        ```
   
   5. **Exception Handling:**
   
      - For possible exceptions (e.g., errors in regular expressions), ensure 
proper try-catch handling to avoid affecting the request flow.
   
   
   


-- 
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-unsubscr...@shenyu.apache.org

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

Reply via email to