增加删除API节点功能

This commit is contained in:
GoEdgeLab
2020-10-10 20:41:33 +08:00
parent 444ca7535e
commit 32ac0d62d3
5 changed files with 39 additions and 1 deletions

View File

@@ -0,0 +1,22 @@
package api
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
type DeleteAction struct {
actionutils.ParentAction
}
func (this *DeleteAction) RunPost(params struct {
NodeId int64
}) {
_, err := this.RPC().APINodeRPC().DeleteAPINode(this.AdminContext(), &pb.DeleteAPINodeRequest{NodeId: params.NodeId})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}

View File

@@ -16,6 +16,7 @@ func init() {
Prefix("/api").
Get("", new(IndexAction)).
GetPost("/node/createPopup", new(node.CreatePopupAction)).
Post("/delete", new(DeleteAction)).
EndAll()
})
}

View File

@@ -29,6 +29,7 @@ func (this *CreateAddrPopupAction) RunPost(params struct {
params.Must.
Field("addr", params.Addr).
Require("请输入访问地址")
host, port, err := net.SplitHostPort(params.Addr)
if err != nil {
this.FailField("addr", "错误的访问地址")