iris
iris copied to clipboard
How to customize the / segmentation rules of the controller? Or implement annotation routing
How to customize the / segmentation rules of the controller? Or implement annotation routing
It seems that the initial MVC routing is not what you want most of the time, because many times it is a path composed of several words. For example, getUserInfo mostly just wants to generate / userinfo
In most cases, live template is used to generate code, so writing in another function requires a lot of work. Can we customize this rule or have annotations to generate routes
Hello @a97077088,
Of course, you can customize the HTTP request controller's method through BeforeActivation
controller's method. Example at: https://github.com/kataras/iris/blob/9cf6f9fa5ed0f3cff1d4504e7b631782bfde8ee1/_examples/mvc/basic/main.go#L92
https://github.com/kataras/iris/blob/9cf6f9fa5ed0f3cff1d4504e7b631782bfde8ee1/_examples/mvc/basic/main.go#L110
About method annotations, there is no such feature in Go programming language, you'll need a generator (a second executable tool that runs on the source code of your project) for that.
BeforeActivation does not seem to be available under the live template, because the live template cannot control the existing code in most cases. Is there a way to customize this generation rule? Or implement the same annotation routing as beego using reflection
Nice to hear from you, god of web frameworks
does not seem to be available under the live template, because the live template cannot control the existing code in most cases.
Hello @a97077088. I didn't get it, what "live template" are you reffering to? Thanks
Or implement the same annotation routing as beego using reflection
Annotation is not a feature available in Go Programming Language with reflection. You need a code generator (2nd tool, see my previous answer).
Live template is a fast code generation method provided by Goland ide
It can generate code quickly. I preset some crud instructions, but it seems that path has encountered a big problem. The problem is that the uppercase letter of iris is divided into / directory
Do you have a real-time chat tool? I can show you
Live template is a fast code generation method provided by Goland ide
I've never used Goland IDE, I am VS Code fan from its first steps. But if you have experience with that feature of Goland IDE, we can work together to support the code generation you need.
but it seems that path has encountered a big problem. The problem is that the uppercase letter of iris is divided into / directory
I've already posted how to customize your paths and disable that auto-method binding to paths. This is not a problem.
Do you have a real-time chat tool? I can show you
Yes of course we do, you can contact me directly at https://chat.iris-go.com.
@Kataras, thank you for your guidance. I will write a route generator based on ast analysis for iris after my recent work
I'm excited to see that @aadog, don't hesitate to ping me for help!