[Question] Suggest simple the route config or Give some help video
Question
Suggest simple the route config?
I want to route to a python service behind the nacos.
the request uri:“someServiceApi/someModule/doSomething” the actual uri in the python service: "someModule/doSomething"
To config the route, it seems that i need do below steps:
- config boot strap server, let it connect to nacos server.
- use httpProcess/Rewrite to strip the prefix "someServiceApi".
- use Proxy/SpringCloud to route via serviceId "someServiceApi".
Why can not do this one-stop in one plugin? For example, There is a discovery config in divide plugin, Just add a pathRewrite on form to complete the workflow. PS: I can not successed with the discovery config in divide, never.
help video
I hope can get some video about common route scenario:
- route to pure http service, contains pathRewrite, request header modify, oauth integration, etc.
- route to http service(write in any program lang, not just java spring) behind service discovery
- route to websocket service
- route to websocket service behind service discovery
thanks for your suggestions
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
-
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.
-
Configuration Validation:
- In the frontend form, add basic validation for regular expressions to prompt users to enter the correct format.
-
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.
-
Logging:
-
Add logs before and after path rewriting to facilitate debugging and issue troubleshooting.
if (matcher.find()) { String newPath = matcher.replaceAll(ruleHandle.getPathRewriteReplacement()); LOG.info("Path rewritten from {} to {}", originalPath, newPath); // ... }
-
-
Exception Handling:
- For possible exceptions (e.g., errors in regular expressions), ensure proper try-catch handling to avoid affecting the request flow.