package http import ( "bom_server/configs" "github.com/gin-gonic/gin" "net/http" "time" ) func InitRouter() *gin.Engine { gin.SetMode(configs.ApiSetting.Mode) router := gin.Default() //测试心跳的路由 router.GET("/hbsdata", func(context *gin.Context) { context.String(200, "ok") }) router.POST("/bom/export", Export) router.POST("/bom_matching/refresh", RefreshBomMatchingGoods) router.POST("/bom_matching/update", UpdateBomMatching) router.POST("/bom_item/update", UpdateBomItem) return router } func InitApiServer() (err error) { router := InitRouter() s := &http.Server{ Addr: ":" + configs.ApiSetting.ApiPort, Handler: router, ReadTimeout: 20 * time.Second, WriteTimeout: 20 * time.Second, MaxHeaderBytes: 1 << 20, } return s.ListenAndServe() }