package controller import ( "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/os/gctx" "36wisdom/common/auth" ) // Register 注册全部路由分组;各业务控制器在对应任务中挂载。 func Register(s *ghttp.Server) { s.Use(ghttp.MiddlewareHandlerResponse) s.BindHandler("GET:/ping", func(r *ghttp.Request) { r.Response.Write("pong") }) secret := g.Cfg().MustGet(gctx.New(), "auth.secret").String() // 前台:公开接口(注册/登录),鉴权接口按模块挂载 s.Group("/api", func(g *ghttp.RouterGroup) { g.Bind(Parent) g.Group("/", func(g *ghttp.RouterGroup) { g.Middleware(auth.Middleware(secret, "")) g.Bind(Child, Strategy, Level, LevelPlay) }) }) }