Commit c4db0a51 by zhengqiuyun86

初始化

parent 7db34074
......@@ -7,7 +7,6 @@ require (
github.com/go-playground/validator/v10 v10.11.0
github.com/go-redis/redis v6.15.9+incompatible
github.com/olivere/elastic/v7 v7.0.32
github.com/swaggo/gin-swagger v1.5.2
gorm.io/driver/mysql v1.2.2
gorm.io/gorm v1.22.4
)
......
package main
import (
"fmt"
"git.168cad.top/zhengqiuyun/rym-util/es"
"git.168cad.top/zhengqiuyun/rym-util/log"
"git.168cad.top/zhengqiuyun/rym-util/mysqlrym"
"git.168cad.top/zhengqiuyun/rym-util/redis"
"git.168cad.top/zhengqiuyun/rym-util/router"
......@@ -11,5 +13,11 @@ func main() {
mysqlrym.TestLog()
es.TestLog()
redis.TestLog()
router.InitGinEngine()
c := router.InitGinEngine()
portAddr := fmt.Sprintf(":%d", 8080)
log.Info(fmt.Sprintf("web start in port%s", portAddr))
err := c.Run(portAddr)
if err != nil {
panic(err)
}
}
package router
import (
"git.168cad.top/zhengqiuyun/rym-util/conf"
"git.168cad.top/zhengqiuyun/rym-util/router/validator"
"github.com/gin-gonic/gin"
swaggerFiles "github.com/swaggo/files"
"github.com/swaggo/gin-swagger"
"github.com/gin-gonic/gin/render"
"net/http"
)
......@@ -14,14 +12,9 @@ func InitGinEngine() *gin.Engine {
c := gin.New()
//便于工具监测
c.GET("/favicon.ico", func(c *gin.Context) {
c.JSON(http.StatusOK, nil)
c.Render(http.StatusOK, render.String{})
})
//自定义验证器
validator.RegisterValidate()
if conf.Env == "dev" || conf.Env == "test" {
//swagger
c.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
}
return c
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment