Browse Source

fix code style

develop
zhangshu 10 months ago
parent
commit
32f3ddef4f
  1. 12
      youtube_collection_server/main.go

12
youtube_collection_server/main.go

@ -3,7 +3,7 @@ package main
import ( import (
"fmt" "fmt"
utils "youtube_collection_server/Utils" utils "youtube_collection_server/Utils"
. "youtube_collection_server/config" config "youtube_collection_server/config"
"youtube_collection_server/controller" "youtube_collection_server/controller"
"youtube_collection_server/middle" "youtube_collection_server/middle"
@ -11,22 +11,22 @@ import (
) )
func main() { func main() {
InitConfig() config.InitConfig()
// 创建一个默认的路由引擎 // 创建一个默认的路由引擎
router := gin.Default() router := gin.Default()
//初始化路由 //初始化路由
initRouter(router) initRouter(router)
Logger.Infof("服务器启动成功...端口:%d", MyEnv.Server.Port) config.Logger.Infof("服务器启动成功...端口:%d", config.MyEnv.Server.Port)
router.Use(middle.Cors()) router.Use(middle.Cors())
err := router.Run(fmt.Sprintf(":"+"%d", MyEnv.Server.Port)) err := router.Run(fmt.Sprintf(":"+"%d", config.MyEnv.Server.Port))
if err != nil { if err != nil {
Logger.Error("服务器启动失败") config.Logger.Error("服务器启动失败")
return return
} }
} }
func initRouter(router *gin.Engine) { func initRouter(router *gin.Engine) {
router.Use(utils.LoggerToFile(MyEnv.Log.LogEnv, MyEnv.Log.LogPath)) router.Use(utils.LoggerToFile(config.MyEnv.Log.LogEnv, config.MyEnv.Log.LogPath))
noAuth := router.Group("") noAuth := router.Group("")
{ {
noAuth.GET("/test", controller.UserController.Test) noAuth.GET("/test", controller.UserController.Test)

Loading…
Cancel
Save