Commit 26d52b9f by mushishixian

路由独立文件

parent 274fd0d8
......@@ -5,9 +5,9 @@ import (
"github.com/gin-gonic/gin"
"github.com/micro/go-micro/v2/web"
"search_server/boot"
"search_server/controller"
_ "search_server/controller"
"search_server/pkg/config"
"search_server/routes"
)
func main() {
......@@ -18,12 +18,8 @@ func main() {
panic(err)
}
gin.SetMode(config.Get("web.mode").String())
r := gin.New()
//路由
r.POST("/search/bom/autospu", controller.AutoSpu)
r.POST("/search/bom/recommend", controller.Recommend)
r := routes.InitRouter()
port := config.Get("web.port").String()
//web改成micro 就是grpc,并直接注册到etcd里面
......
package routes
import (
"github.com/gin-gonic/gin"
"search_server/controller"
)
//初始化路由
func InitRouter() *gin.Engine {
r := gin.New()
r.Use(gin.Logger())
r.Use(gin.Recovery())
//路由
r.POST("/search/bom/autospu", controller.AutoSpu)
r.POST("/search/bom/recommend", controller.Recommend)
return r
}
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 sign in to comment