seaweedfs/weed/server/raft_server_handlers.go

22 lines
523 B
Go
Raw Normal View History

package weed_server
import (
"github.com/chrislusf/seaweedfs/weed/operation"
2018-07-22 08:39:10 +08:00
"net/http"
)
func (s *RaftServer) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request)) {
s.router.HandleFunc(pattern, handler)
}
func (s *RaftServer) statusHandler(w http.ResponseWriter, r *http.Request) {
ret := operation.ClusterStatusResult{
IsLeader: s.topo.IsLeader(),
Peers: s.Peers(),
}
if leader, e := s.topo.Leader(); e == nil {
ret.Leader = leader
}
writeJsonQuiet(w, r, http.StatusOK, ret)
}