mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-13 02:22:27 +08:00
init commit
This commit is contained in:
63
air/controller/registry_controller.go
Normal file
63
air/controller/registry_controller.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"air/entity"
|
||||
"flswld.com/logger"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// 注册HTTP服务
|
||||
func (c *Controller) registerHttpService(context *gin.Context) {
|
||||
inst := new(entity.Instance)
|
||||
err := context.ShouldBindJSON(inst)
|
||||
if err != nil {
|
||||
logger.LOG.Error("parse json error: %v", err)
|
||||
return
|
||||
}
|
||||
c.service.RegisterHttpService(*inst)
|
||||
context.JSON(200, gin.H{
|
||||
"code": 0,
|
||||
})
|
||||
}
|
||||
|
||||
// 取消注册HTTP服务
|
||||
func (c *Controller) cancelHttpService(context *gin.Context) {
|
||||
inst := new(entity.Instance)
|
||||
err := context.ShouldBindJSON(inst)
|
||||
if err != nil {
|
||||
logger.LOG.Error("parse json error: %v", err)
|
||||
return
|
||||
}
|
||||
c.service.CancelHttpService(*inst)
|
||||
context.JSON(200, gin.H{
|
||||
"code": 0,
|
||||
})
|
||||
}
|
||||
|
||||
// 注册RPC服务
|
||||
func (c *Controller) registerRpcService(context *gin.Context) {
|
||||
inst := new(entity.Instance)
|
||||
err := context.ShouldBindJSON(inst)
|
||||
if err != nil {
|
||||
logger.LOG.Error("parse json error: %v", err)
|
||||
return
|
||||
}
|
||||
c.service.RegisterRpcService(*inst)
|
||||
context.JSON(200, gin.H{
|
||||
"code": 0,
|
||||
})
|
||||
}
|
||||
|
||||
// 取消注册RPC服务
|
||||
func (c *Controller) cancelRpcService(context *gin.Context) {
|
||||
inst := new(entity.Instance)
|
||||
err := context.ShouldBindJSON(inst)
|
||||
if err != nil {
|
||||
logger.LOG.Error("parse json error: %v", err)
|
||||
return
|
||||
}
|
||||
c.service.CancelRpcService(*inst)
|
||||
context.JSON(200, gin.H{
|
||||
"code": 0,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user