印度包网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

73 lines
1.5 KiB

package routers
import (
"runtime"
"server/common"
"server/config"
"server/modules/web/middleware"
"server/modules/web/providers/all"
"github.com/gin-gonic/gin"
"github.com/liangdas/mqant/log"
)
func SetUpRouter() *gin.Engine {
if config.GetBase().Release {
gin.SetMode(gin.ReleaseMode)
// 禁用控制台颜色
gin.DisableConsoleColor()
} else {
gin.SetMode(gin.DebugMode)
}
r := gin.New()
// 跨域处理
r.Use(middleware.CrosHandler())
// r.Use(middleware.RateLimitMiddleware())
r.Use(gin.RecoveryWithWriter(log.LogBeego(), func(c *gin.Context, err interface{}) {
buf := make([]byte, 1024)
runtime.Stack(buf, false)
log.Error("panic(%+v), stack:\n%s", err, string(buf))
}))
// r.Use(middleware.UserLimitMiddleware())
r.GET("/", common.HealthCheck)
auth := r.Group("")
auth.Use(middleware.TokenMiddleWare())
auth.Use(middleware.WhiteMiddleWare())
// auth.Use(middleware.RateLimitMiddleware())
{
sys(auth)
account(auth)
user(auth)
balance(auth)
activity(auth)
notice(auth)
mail(auth)
ftp(auth)
game(auth)
h5(auth)
firstpage(auth)
vip(auth)
share(auth)
task(auth)
telegram(auth)
ad(auth)
customer(auth)
rank(auth)
}
provider := r.Group("provider/")
if config.GetBase().Release {
provider.Use(middleware.WhiteIPs())
}
all.InitRouter(provider)
// td := provider.Group("tada")
// tada.Tada(td)
// ac := provider.Group("awc")
// awc.AWC(ac)
// pg := provider.Group("pg")
// pgsoft.PGSoft(pg)
return r
}