int_router.go 776 B

123456789101112131415161718192021222324252627282930313233343536
  1. package router
  2. import (
  3. //"github.com/go-admin-team/go-admin-core/sdk/pkg"
  4. "os"
  5. common "git.cestong.com.cn/cecf/hx-admin-server/common/middleware"
  6. "github.com/gin-gonic/gin"
  7. log "github.com/go-admin-team/go-admin-core/logger"
  8. "github.com/go-admin-team/go-admin-core/sdk"
  9. )
  10. // InitRouter 路由初始化,不要怀疑,这里用到了
  11. func InitRouter() {
  12. var r *gin.Engine
  13. h := sdk.Runtime.GetEngine()
  14. if h == nil {
  15. log.Fatal("not found engine...")
  16. os.Exit(-1)
  17. }
  18. switch h.(type) {
  19. case *gin.Engine:
  20. r = h.(*gin.Engine)
  21. default:
  22. log.Fatal("not support other engine")
  23. os.Exit(-1)
  24. }
  25. authMiddleware, err := common.AuthInit()
  26. if err != nil {
  27. log.Fatalf("JWT Init Error, %s", err.Error())
  28. }
  29. // 注册业务路由
  30. initRouter(r, authMiddleware)
  31. }