zeromicro / go-zero

A cloud-native Go microservices framework with cli tool for productivity.
https://go-zero.dev
MIT License
29.2k stars 3.95k forks source link

How to match /{suffix...} in go-zero? #4428

Open Dong148 opened 1 week ago

zhoushuguang commented 1 week ago

Can you describe it in more detail?

Dong148 commented 2 days ago

Can you describe it in more detail?

Issue Description

I am currently developing a gateway application that requires dynamic routing based on the suffix of the URL path. I am considering migrating our existing system to the go-zero framework to leverage its built-in features such as load balancing and distributed tracing. However, I’ve encountered a limitation in the go-zero routing system that may impede this migration.

Expected Behavior

I would like to confirm whether the go-zero routing system supports a pattern that allows for wildcard suffix matching, similar to /service/{suffix...}. This pattern should match any request path that starts with /service/ and is followed by any suffix. The gateway should be capable of capturing the entire suffix and routing it to the appropriate downstream service.

Use Case

The gateway should be able to route requests of a project to different module and API versions based on the suffix. For example, /awesome/api/v1/resource/... would direct requests to module-api, version-1 of the project-awesome. The gateway is intended to aggregate multiple microservices behind a single endpoint, with the suffix determining which specific service the request should be routed to, and apply queuing, lots of monitoring and functions.