32 lines
550 B
Go
32 lines
550 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"joylink.club/bj-rtsts-server/db/dbquery"
|
||
|
|
||
|
"github.com/gin-gonic/gin"
|
||
|
"joylink.club/bj-rtsts-server/config"
|
||
|
"joylink.club/bj-rtsts-server/db"
|
||
|
"joylink.club/bj-rtsts-server/logger"
|
||
|
)
|
||
|
|
||
|
func InitServer() *gin.Engine {
|
||
|
config.LoadConfig()
|
||
|
fmt.Println("数据源配置为:", config.Config.Datasource.Dsn)
|
||
|
err := logger.InitLogger()
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
|
||
|
err = db.InitDb()
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
dbquery.SetDefault(db.DB)
|
||
|
|
||
|
engine := gin.New()
|
||
|
engine.Use(logger.GinLogger())
|
||
|
return engine
|
||
|
}
|