代码拉取完成,页面将自动刷新
package main
import (
"deeptrain/auth"
allauth "deeptrain/auth/app"
"deeptrain/auth/oauth"
"deeptrain/connection"
"deeptrain/market"
"deeptrain/middleware"
"deeptrain/pay"
"log"
"github.com/gin-gonic/gin"
"github.com/spf13/viper"
)
func main() {
viper.SetConfigFile("config.yaml")
if err := viper.ReadInConfig(); err != nil {
log.Fatalf("Error reading config file, %s", err)
}
cache := connection.ConnectRedis()
db := connection.ConnectMySQL()
if viper.GetBool("debug") {
gin.SetMode(gin.DebugMode)
} else {
gin.SetMode(gin.ReleaseMode)
}
pay.InitPaymentClient()
market.InitMarketingClient()
app := gin.Default()
{
app.Use(middleware.CORSMiddleware())
app.Use(middleware.DBMiddleWare(db, cache))
app.Use(middleware.AuthMiddleware())
app.Use(middleware.ThrottleMiddleware())
}
{
app.POST("/login", auth.LoginView)
app.POST("/register", auth.RegisterView)
app.POST("/reset", auth.ResetView)
app.POST("/verify", auth.VerifyView)
app.POST("/resend", auth.ResendView)
app.GET("/state", auth.StateView)
app.GET("/info", auth.InfoView)
app.POST("/mail/send", auth.EmailLoginView)
app.POST("/mail/verify", auth.EmailLoginVerifyView)
app.POST("/2fa/verify", auth.Verify2FAView)
app.GET("/2fa/enable", auth.Enable2FAView)
app.GET("/2fa/disable", auth.Disable2FAView)
app.GET("/2fa/state", auth.State2FAView)
app.GET("/2fa/activate", auth.Activate2FAView)
app.POST("/settings/password", auth.ChangePasswordView)
app.POST("/settings/email", auth.ChangeEmailView)
app.POST("/settings/verify", auth.ChangeEmailVerifyView)
app.GET("/user/:username", auth.UserView)
app.GET("/avatar/:username", auth.GetAvatarView)
app.POST("/avatar", auth.PostAvatarView)
app.GET("/package/state", auth.PackageView)
pay.Register(app)
oauth.Register(app)
allauth.Register(app)
market.Register(app)
}
defer cache.Close()
defer db.Close()
if err := app.Run(viper.GetString("server.addr")); err != nil {
panic(err)
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。