This commit is contained in:
8
main.go
8
main.go
@@ -49,15 +49,15 @@ func main() {
|
||||
}
|
||||
|
||||
// 5. 创建Gin实例
|
||||
// 根据环境设置Gin模式
|
||||
if conf.Env == config.EnvProduction {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
}
|
||||
router := gin.Default()
|
||||
router := gin.New()
|
||||
router.Use(gin.Recovery())
|
||||
themeManager.RegisterStaticRoutes(router)
|
||||
|
||||
// 初始化Session存储(使用Cookie)
|
||||
store := cookie.NewStore([]byte("your-session-secret")) // 建议从配置文件读取密钥
|
||||
store := cookie.NewStore([]byte("your-session-secret"))
|
||||
store.Options(sessions.Options{
|
||||
Path: "/",
|
||||
MaxAge: 86400 * 7, // 7天
|
||||
@@ -66,8 +66,6 @@ func main() {
|
||||
// 6. 注册中间件
|
||||
router.Use(
|
||||
loggerMiddleware(),
|
||||
gin.Logger(),
|
||||
gin.Recovery(),
|
||||
databaseMiddleware(models.DB),
|
||||
configMiddleware(conf),
|
||||
themeMiddleware(themeManager),
|
||||
|
||||
Reference in New Issue
Block a user