router.go 914 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * @desc:路由绑定
  3. * @company:云南奇讯科技有限公司
  4. * @Author: yixiaohu
  5. * @Date: 2022/2/18 16:23
  6. */
  7. package router
  8. import (
  9. "context"
  10. "github.com/gogf/gf/v2/net/ghttp"
  11. commonRouter "github.com/tiger1103/gfast/v3/internal/app/common/router"
  12. commonService "github.com/tiger1103/gfast/v3/internal/app/common/service"
  13. systemRouter "github.com/tiger1103/gfast/v3/internal/app/system/router"
  14. )
  15. var R = new(Router)
  16. type Router struct{}
  17. func (router *Router) BindController(ctx context.Context, group *ghttp.RouterGroup) {
  18. group.Group("/api/v1", func(group *ghttp.RouterGroup) {
  19. //跨域处理,安全起见正式环境请注释该行
  20. group.Middleware(commonService.Middleware().MiddlewareCORS)
  21. group.Middleware(ghttp.MiddlewareHandlerResponse)
  22. // 绑定后台路由
  23. systemRouter.R.BindController(ctx, group)
  24. // 绑定公共路由
  25. commonRouter.R.BindController(ctx, group)
  26. })
  27. }