goweb/main.go

32 lines
649 B
Go
Raw Normal View History

package main
import (
"github.com/gin-gonic/gin"
2021-08-22 00:13:00 +08:00
"goweb/core"
"goweb/handle"
"goweb/initialization"
"goweb/middleware"
"goweb/route"
)
func main() {
// 初始化相关组件
initialization.Init()
// 初始化Gin
//app := gin.New()
//app.Use(middleware.ZapLogger(), gin.Recovery())
app := gin.Default()
// 定义全局异常处理
app.NoRoute(core.NotFoundErrorHandler())
// 保存接口访问记录
app.Use(middleware.SaveRequestLog(), middleware.CheckDeviceId())
// 初始化路由
route.InitRoute(app)
// 路由初始化完毕,入库所有接口
handle.SaveAllRoute(app.Routes())
// 启动项目
_ = app.Run(":8888")
}