go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

goctl api: custom methods support

Open TnTomato opened this issue 2 years ago • 2 comments

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.

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

TnTomato avatar Dec 26 '23 04:12 TnTomato

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.

kesonan avatar Jan 03 '24 03:01 kesonan

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

TnTomato avatar Jan 03 '24 03:01 TnTomato