3 Star 27 Fork 9

zmh-program/Deeptrain

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 1.94 KB
一键复制 编辑 原始数据 按行查看 历史
Sh1n3zZ 提交于 2025-07-30 18:42 +08:00 . marketing email simple impl
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)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/zmh-program/Deeptrain.git
git@gitee.com:zmh-program/Deeptrain.git
zmh-program
Deeptrain
Deeptrain
main

搜索帮助