1. gin框架中可以使用路由组来实现对路由的分类
package main import "github.com/gin-gonic/gin" func main() { router := gin.Default() userGroup := router.Group("/user") userGroup.GET("/login", LoginHandle) userGroup.POST("/register", RegisterHandle) userGroup.DELETE("/:id", UserDeleteHandle) router.Run(":8000") } func UserDeleteHandle(ctx *gin.Context) { ctx.Writer.WriteString(ctx.Param("id") + "删除了") } func RegisterHandle(ctx *gin.Context) { ctx.Writer.WriteString("register success") } func LoginHandle(ctx *gin.Context) { ctx.Writer.Write([]byte("login success")) }