framework1/app/http/route.go

30 lines
928 B
Go
Raw Normal View History

2024-10-19 22:02:19 +08:00
package http
import (
2024-10-20 22:56:46 +08:00
"github.com/Superdanda/hade/app/http/module/demo"
2024-10-23 17:00:42 +08:00
"github.com/Superdanda/hade/framework/contract"
2024-10-19 22:02:19 +08:00
"github.com/Superdanda/hade/framework/gin"
2024-10-23 17:00:42 +08:00
ginSwagger "github.com/Superdanda/hade/framework/middleware/gin-swagger"
"github.com/Superdanda/hade/framework/middleware/gin-swagger/swaggerFiles"
"github.com/Superdanda/hade/framework/middleware/static"
2024-10-19 22:02:19 +08:00
)
func Routes(core *gin.Engine) {
2024-10-23 17:00:42 +08:00
container := core.GetContainer()
configService := container.MustMake(contract.ConfigKey).(contract.Config)
// 如果配置了swagger则显示swagger的中间件
if configService.GetBool("app.swagger") == true {
core.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
}
2024-10-22 17:06:36 +08:00
// /路径先去./dist目录下查找文件是否存在找到使用文件服务提供服务
2024-10-23 17:00:42 +08:00
core.Use(static.Serve("/", static.LocalFile("./dist", false)))
2024-10-20 22:56:46 +08:00
err := demo.Register(core)
2024-10-27 17:54:21 +08:00
2024-10-20 22:56:46 +08:00
if err != nil {
return
}
2024-10-19 22:02:19 +08:00
}