mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-11-28 13:31:27 +08:00
22 lines
523 B
Go
22 lines
523 B
Go
package weed_server
|
|
|
|
import (
|
|
"github.com/chrislusf/seaweedfs/weed/operation"
|
|
"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)
|
|
}
|