cutego/pkg/gin/index.go

32 lines
779 B
Go
Raw Permalink Normal View History

2023-01-18 17:09:49 +08:00
package gin
import (
"cutego/modules/core/router"
"cutego/pkg/filter"
"cutego/pkg/jwt"
2023-01-18 17:46:25 +08:00
"cutego/pkg/logging"
2023-01-18 17:09:49 +08:00
"cutego/pkg/middleware"
"cutego/pkg/middleware/logger"
"cutego/pkg/websocket"
"cutego/refs"
"github.com/gin-gonic/gin"
)
func init() {
2023-01-18 17:46:25 +08:00
logging.InfoLog("CoolGin init start...")
2023-01-18 17:09:49 +08:00
refs.CoolGin = gin.New()
refs.CoolGin.Use(gin.Logger())
refs.CoolGin.Use(gin.Recovery())
refs.CoolGin.Use(logger.LoggerToFile())
refs.CoolGin.Use(middleware.Recover)
refs.CoolGin.Use(jwt.JWTAuth())
refs.CoolGin.Use(filter.DemoHandler())
// websocket
refs.CoolGin.GET("/websocket", websocket.HandleWebSocketMessage)
// v1版本api
v1Router := refs.CoolGin.Group("/api/v1")
// 加载: 模块路由
router.LoadCoreRouter(v1Router)
2023-01-18 17:46:25 +08:00
logging.InfoLog("CoolGin init end...")
2023-01-18 17:09:49 +08:00
}