| 48 | } |
| 49 | |
| 50 | func (r *MemberRequest) validate() error { |
| 51 | r.Operation = strings.ToLower(r.Operation) |
| 52 | if r.Operation != OperationAdd && r.Operation != OperationRemove { |
| 53 | return fmt.Errorf("operation must be one of [%s]", |
| 54 | strings.Join([]string{OperationAdd, OperationRemove}, ",")) |
| 55 | } |
| 56 | if r.Operation == OperationAdd && r.Peer == "" { |
| 57 | return fmt.Errorf("peer should NOT be empty") |
| 58 | } |
| 59 | return nil |
| 60 | } |
| 61 | |
| 62 | func (handler *RaftHandler) ListPeers(c *gin.Context) { |
| 63 | raftNode, _ := c.MustGet(consts.ContextKeyRaftNode).(*raft.Node) |