Description
How to get all the APIs of each router group in gin? I didn't find the corresponding method.
Comment From: xilu0
Gin's Engine has a Routes method that returns all the routes.
func main() {
r := gin.Default()
api := r.Group("/api")
{
api.GET("/users", getUsers)
api.POST("/users", createUser)
}
// Print all routes
for _, routeInfo := range r.Routes() {
fmt.Printf("Method: %s, Path: %s\n", routeInfo.Method, routeInfo.Path)
}
}
Comment From: ppd324
Is it possible to add features and obtain the API of each group?