直接完成
此提交包含在:
35
main.go
一般檔案
35
main.go
一般檔案
@@ -0,0 +1,35 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
nice "github.com/ekyoung/gin-nice-recovery"
|
||||
"github.com/gin-gonic/gin"
|
||||
"integrity-checkin/dao"
|
||||
"integrity-checkin/pkg/app"
|
||||
"integrity-checkin/pkg/httpclient"
|
||||
"integrity-checkin/router"
|
||||
"integrity-checkin/service"
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
Setup()
|
||||
httpclient.Setup()
|
||||
engine := gin.New()
|
||||
engine.Use(gin.Logger(),
|
||||
nice.Recovery(func(c *gin.Context, err interface{}) {
|
||||
aw := app.NewWrapper(c)
|
||||
aw.Error("内部错误,请重试:" + fmt.Sprintf("%v", err)).SendJSON()
|
||||
}))
|
||||
dao.Setup()
|
||||
service.Setup()
|
||||
router.Setup(engine)
|
||||
err := engine.Run(fmt.Sprintf(":%v", "8964"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
func Setup() {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
}
|
新增問題並參考
封鎖使用者