32 lines
649 B
Go
32 lines
649 B
Go
package main
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"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")
|
|
}
|