🎨 更新环境配置,添加 Dockerfile,优化代码结构
This commit is contained in:
@@ -10,5 +10,6 @@ func bizModel() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.echol.cn/loser/Go-Web-Template/server/config"
|
||||
"git.echol.cn/loser/Go-Web-Template/server/global"
|
||||
"git.echol.cn/loser/Go-Web-Template/server/initialize/internal"
|
||||
@@ -38,6 +40,8 @@ func initPgSqlDatabase(p config.Pgsql) *gorm.DB {
|
||||
sqlDB, _ := db.DB()
|
||||
sqlDB.SetMaxIdleConns(p.MaxIdleConns)
|
||||
sqlDB.SetMaxOpenConns(p.MaxOpenConns)
|
||||
sqlDB.SetConnMaxLifetime(30 * time.Minute)
|
||||
sqlDB.SetConnMaxIdleTime(10 * time.Minute)
|
||||
return db
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,10 +51,11 @@ func Routers() *gin.Engine {
|
||||
// Router.Static("/assets", "./dist/assets") // dist里面的静态资源
|
||||
// Router.StaticFile("/", "./dist/index.html") // 前端网页入口页面
|
||||
|
||||
// 跨域,如需跨域可以打开下面的注释
|
||||
Router.Use(middleware.Cors()) // 直接放行全部跨域请求(必须在 StaticFS 之前注册,否则静态文件不带 CORS 头)
|
||||
// Router.Use(middleware.CorsByRules()) // 按照配置的规则放行跨域请求
|
||||
Router.StaticFS(global.GVA_CONFIG.Local.StorePath, justFilesFilesystem{http.Dir(global.GVA_CONFIG.Local.StorePath)})
|
||||
// Router.Use(middleware.LoadTls()) // 如果需要使用https 请打开此中间件 然后前往 core/server.go 将启动模式 更变为 Router.RunTLS("端口","你的cre/pem文件","你的key文件")
|
||||
// 跨域,如需跨域可以打开下面的注释
|
||||
Router.Use(middleware.Cors()) // 直接放行全部跨域请求
|
||||
// Router.Use(middleware.CorsByRules()) // 按照配置的规则放行跨域请求
|
||||
// global.GVA_LOG.Info("use middleware cors")
|
||||
docs.SwaggerInfo.BasePath = global.GVA_CONFIG.System.RouterPrefix
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// 占位方法,保证文件可以正确加载,避免go空变量检测报错,请勿删除。
|
||||
func holder(routers ...*gin.RouterGroup) {
|
||||
_ = routers
|
||||
_ = router.RouterGroupApp
|
||||
|
||||
@@ -2,6 +2,7 @@ package initialize
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.echol.cn/loser/Go-Web-Template/server/task"
|
||||
|
||||
"github.com/robfig/cron/v3"
|
||||
|
||||
Reference in New Issue
Block a user