29 lines
803 B
Go
29 lines
803 B
Go
package web
|
|
|
|
import (
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/lego/core/cbase"
|
|
"go_dreamfactory/lego/sys/gin"
|
|
)
|
|
|
|
/*
|
|
web api 服务组件
|
|
*/
|
|
type Api_Comp struct {
|
|
cbase.ModuleCompBase
|
|
options *Options //模块参数
|
|
module *Web //当前模块对象
|
|
gin gin.ISys //gin 框架 web的热门框架
|
|
}
|
|
|
|
//组件初始化接口 启动web服务 并注册api
|
|
func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
|
err = this.ModuleCompBase.Init(service, module, comp, options)
|
|
this.options = options.(*Options)
|
|
this.module = module.(*Web)
|
|
this.gin, err = gin.NewSys(gin.SetListenPort(this.options.Port))
|
|
this.gin.POST("/register", this.Register)
|
|
this.gin.POST("/serverlist", this.ServerList)
|
|
return
|
|
}
|