1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package router
- import (
- "os"
- common "go-admin/common/middleware"
- "github.com/gin-gonic/gin"
- log "github.com/go-admin-team/go-admin-core/logger"
- "github.com/go-admin-team/go-admin-core/sdk"
- )
- // InitRouter 路由初始化,不要怀疑,这里用到了
- func InitRouter() {
- var r *gin.Engine
- h := sdk.Runtime.GetEngine()
- if h == nil {
- log.Fatal("not found engine...")
- os.Exit(-1)
- }
- switch t := h.(type) {
- case *gin.Engine:
- r = t
- default:
- log.Fatal("not support other engine")
- os.Exit(-1)
- }
- // the jwt middleware
- authMiddleware, err := common.AuthInit()
- if err != nil {
- log.Fatalf("JWT Init Error, %s", err.Error())
- }
- // 注册系统路由
- // InitSysRouter(r, authMiddleware)
- // 注册业务路由
- // TODO: 这里可存放业务路由,里边并无实际路由只有演示代码
- InitExamplesRouter(r, authMiddleware)
- }
|