forked from newbee-ltd/newbee-mall-api-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter.go
55 lines (52 loc) · 1.71 KB
/
router.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package initialize
import (
"github.com/gin-gonic/gin"
"main.go/global"
"main.go/middleware"
"main.go/router"
"net/http"
)
func Routers() *gin.Engine {
var Router = gin.Default()
Router.StaticFS(global.GVA_CONFIG.Local.Path, http.Dir(global.GVA_CONFIG.Local.Path)) // 为用户头像和文件提供静态地址
//Router.Use(middleware.LoadTls()) // 打开就能玩https了
global.GVA_LOG.Info("use middleware logger")
// 跨域
Router.Use(middleware.Cors()) // 如需跨域可以打开
global.GVA_LOG.Info("use middleware cors")
// 方便统一添加路由组前缀 多服务器上线使用
//商城后管路由
manageRouter := router.RouterGroupApp.Manage
ManageGroup := Router.Group("manage-api")
PublicGroup := Router.Group("")
{
// 健康监测
PublicGroup.GET("/health", func(c *gin.Context) {
c.JSON(200, "ok")
})
}
{
//商城后管路由初始化
manageRouter.InitManageAdminUserRouter(ManageGroup)
manageRouter.InitManageGoodsCategoryRouter(ManageGroup)
manageRouter.InitManageGoodsInfoRouter(ManageGroup)
manageRouter.InitManageCarouselRouter(ManageGroup)
manageRouter.InitManageIndexConfigRouter(ManageGroup)
manageRouter.InitManageOrderRouter(ManageGroup)
}
//商城前端路由
mallRouter := router.RouterGroupApp.Mall
MallGroup := Router.Group("api")
{
// 商城前端路由
mallRouter.InitMallCarouselIndexRouter(MallGroup)
mallRouter.InitMallGoodsInfoIndexRouter(MallGroup)
mallRouter.InitMallGoodsCategoryIndexRouter(MallGroup)
mallRouter.InitMallUserRouter(MallGroup)
mallRouter.InitMallUserAddressRouter(MallGroup)
mallRouter.InitMallShopCartRouter(MallGroup)
mallRouter.InitMallOrderRouter(MallGroup)
}
global.GVA_LOG.Info("router register success")
return Router
}