mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-04 00:10:25 +08:00
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package router
|
|
|
|
import (
|
|
"mayfly-go/base/ctx"
|
|
"mayfly-go/server/devops/api"
|
|
"mayfly-go/server/devops/application"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func InitMachineRouter(router *gin.RouterGroup) {
|
|
m := &api.Machine{MachineApp: application.MachineApp}
|
|
machines := router.Group("machines")
|
|
{
|
|
machines.GET("", func(c *gin.Context) {
|
|
ctx.NewReqCtxWithGin(c).Handle(m.Machines)
|
|
})
|
|
|
|
machines.GET(":machineId/stats", func(c *gin.Context) {
|
|
ctx.NewReqCtxWithGin(c).Handle(m.MachineStats)
|
|
})
|
|
|
|
saveMachine := ctx.NewLogInfo("保存机器信息")
|
|
machines.POST("", func(c *gin.Context) {
|
|
ctx.NewReqCtxWithGin(c).
|
|
WithLog(saveMachine).
|
|
Handle(m.SaveMachine)
|
|
})
|
|
|
|
delMachine := ctx.NewLogInfo("删除机器")
|
|
machines.DELETE(":machineId", func(c *gin.Context) {
|
|
ctx.NewReqCtxWithGin(c).
|
|
WithLog(delMachine).
|
|
Handle(m.DeleteMachine)
|
|
})
|
|
|
|
closeCli := ctx.NewLogInfo("关闭机器客户端")
|
|
machines.DELETE(":machineId/close-cli", func(c *gin.Context) {
|
|
ctx.NewReqCtxWithGin(c).WithLog(closeCli).Handle(m.CloseCli)
|
|
})
|
|
|
|
machines.GET(":machineId/terminal", m.WsSSH)
|
|
}
|
|
}
|