-
Notifications
You must be signed in to change notification settings - Fork 0
/
route.go
27 lines (22 loc) · 925 Bytes
/
route.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
package http
import (
"github.com/Fcou/web-frame/app/http/module/demo"
"github.com/Fcou/web-frame/framework/contract"
"github.com/Fcou/web-frame/framework/gin"
ginSwagger "github.com/Fcou/web-frame/framework/middleware/gin-swagger"
"github.com/Fcou/web-frame/framework/middleware/gin-swagger/swaggerFiles"
"github.com/Fcou/web-frame/framework/middleware/static"
)
// Routes 绑定业务层路由
func Routes(r *gin.Engine) {
container := r.GetContainer()
configService := container.MustMake(contract.ConfigKey).(contract.Config)
// /路径先去./dist目录下查找文件是否存在,找到使用文件服务提供服务
r.Use(static.Serve("/", static.LocalFile("./dist", false)))
// 如果配置了swagger,则显示swagger的中间件
if configService.GetBool("app.swagger") == true {
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
}
// 动态路由定义
demo.Register(r)
}