zeromicro / go-zero

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

goctl api: custom methods support #3815

Open TnTomato opened 10 months ago

TnTomato commented 10 months ago

Is your feature request related to a problem? Please describe. I'm designing APIs for a massive system depends on microservices. It's nice not to use any frameworks to ensure flexibility due to LESS IS MORE, but time limits, our team needs to finish our work in an extremely short time. So I choose go-zero as a framework and a tool as well. Learning from Google's API Improvement Proposals of Custom Methods, it provides a means for an API's vocabulary to adhere to user intent, which can make API definitions more flexible.

E.g.

post /users/:userId:doSomething

But obviously, it conflits with the current path parameter definition. I hope this is considered in the road map.

Describe the solution you'd like Some solutions in my opinion:

  1. Use {} to define path parameters

    post /users/{userId}:doSomething

    Easy to implement but it's not forward-compatible.

  2. Leave it as is

    post /users/:userId:doSomething

    It's hard to deal with some edge cases.

Describe alternatives you've considered Provide an option to add some custom routes in routes.go.

Additional context I'm glad to offer help once I'm available.

kesonan commented 9 months ago

First of all, I understand your thoughts and appreciate your feedback, but from a compatibility perspective and in the long run, this is not planned to be supported because this is go-zero's design and we will not change the original design to break compatible.

TnTomato commented 9 months ago

got it. I'll try figuring out a workaround. thanks for you reply.