123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package router
- import (
- "net/http"
- "github.com/gin-contrib/gzip"
- "github.com/gin-contrib/sessions"
- "github.com/gin-contrib/sessions/cookie"
- "github.com/gin-gonic/gin"
- "nn.daxia.dev/handler/api"
- "nn.daxia.dev/handler/common"
- "nn.daxia.dev/router/middleware"
- )
- // 载入中间件
- func Load(g *gin.Engine, mw ...gin.HandlerFunc) *gin.Engine {
- store := cookie.NewStore([]byte("gamee-389aec83c8f9"))
- g.Use(gin.Logger())
- g.Use(gin.Recovery())
- g.Use(gzip.Gzip(gzip.DefaultCompression))
- g.Use(middleware.GlobalError())
- g.Use(middleware.NoCache())
- g.Use(middleware.Options())
- g.Use(middleware.Secure())
- g.Use(sessions.Sessions("default", store))
- g.Use(mw...)
- g.NoRoute(func(ctx *gin.Context) {
- ctx.String(http.StatusNotFound, "incorrect api router")
- })
- g.GET("/connect", gin.WrapF(Index))
- checkRoute := g.Group("/check")
- {
- checkRoute.GET("/ping", func(ctx *gin.Context) {
- ctx.String(http.StatusOK, "ping")
- })
- }
- ntApiRoute := g.Group("/api/nt")
- {
- ntApiRoute.POST("notify", api.Notify) //通知接口
- }
- //内部通讯业务
- bsApiRoute := g.Group("/api/bs")
- {
- bsApiRoute.POST("/perform", common.Dispatch)
- // gameQZNNApi := bsApiRoute.Group("/qznn")
- // {
- // gameQZNNApi.POST("ready", game.QznnReady)
- // gameQZNNApi.POST("choose_master", game.QznnChooseMaster)
- // gameQZNNApi.POST("choose_mul", game.QznnChooseMul)
- // gameQZNNApi.POST("open", game.QznnOpen)
- // }
- }
- return g
- }
|