package gm 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 *GM //当前模块对象 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.(*GM) this.gin, err = gin.NewSys(gin.SetListenPort(this.options.Port)) this.gin.POST("/register", this.Register) this.gin.GET("/serverlist", this.ServerList) this.gin.GET("/createnotify", this.CreateNotify) return }