Is it possible to sub-group routes?
i.e.
func main (){
r = gin.Default()
v1 := r.Group("/api/v1"){
auth := v1.Group("/auth/"){
auth.GET("/users", userListHandler)
auth.POST("/login", loginHandler)
}
}
}
This would allow mixing and matching api versions and functions.
That is easy to try:
package main
import "github.com/gin-gonic/gin"
func main() {
r := gin.Default()
v1 := r.Group("/api/v1")
{
auth := v1.Group("/auth")
{
auth.GET("/", func(c *gin.Context) {
c.JSON(200, gin.H{
"v1-auth": true,
})
})
}
}
r.Run() // listen and serve on 0.0.0.0:8080
}
Running this logs
[GIN-debug] GET /api/v1/auth/ --> main.main.func1 (3 handlers)
So yes, this is possible.
@devshell yes
Most helpful comment
That is easy to try:
Running this logs
So yes, this is possible.