bbs/app/http/kernel.go

27 lines
745 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package http
import (
"bbs/app/provider/database_connect"
"github.com/Superdanda/hade/framework"
"github.com/Superdanda/hade/framework/gin"
)
// NewHttpEngine 创建了一个绑定了路由的Web引擎
func NewHttpEngine(container *framework.HadeContainer) (*gin.Engine, error) {
//绑定服务
container.Bind(&database_connect.DatabaseConnectProvider{})
// 设置为Release为的是默认在启动中不输出调试信息
gin.SetMode(gin.ReleaseMode)
// 默认启动一个Web引擎
r := gin.Default()
r.SetContainer(container)
// 业务绑定路由操作
Routes(r)
// 返回绑定路由后的Web引擎
// 对业务模型进行注册,通过注册名获取业务模型类型信息
TypeRegister(container)
return r, nil
}