You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
495 B

  1. package weed_server
  2. import (
  3. "net/http"
  4. )
  5. type ClusterStatusResult struct {
  6. IsLeader bool `json:"IsLeader,omitempty"`
  7. Leader string `json:"Leader,omitempty"`
  8. Peers []string `json:"Peers,omitempty"`
  9. }
  10. func (s *RaftServer) StatusHandler(w http.ResponseWriter, r *http.Request) {
  11. ret := ClusterStatusResult{
  12. IsLeader: s.topo.IsLeader(),
  13. Peers: s.Peers(),
  14. }
  15. if leader, e := s.topo.Leader(); e == nil {
  16. ret.Leader = leader
  17. }
  18. writeJsonQuiet(w, r, http.StatusOK, ret)
  19. }