2013-12-09 21:34:05 +00:00
|
|
|
package weed_server
|
|
|
|
|
|
|
|
import (
|
2016-06-03 01:09:14 +00:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/operation"
|
2018-07-22 00:39:10 +00:00
|
|
|
"net/http"
|
2013-12-09 21:34:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (s *RaftServer) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request)) {
|
|
|
|
s.router.HandleFunc(pattern, handler)
|
|
|
|
}
|
|
|
|
|
2014-02-04 09:10:07 +00:00
|
|
|
func (s *RaftServer) statusHandler(w http.ResponseWriter, r *http.Request) {
|
2014-04-15 16:30:08 +00:00
|
|
|
ret := operation.ClusterStatusResult{
|
|
|
|
IsLeader: s.topo.IsLeader(),
|
|
|
|
Peers: s.Peers(),
|
|
|
|
}
|
2014-04-11 23:23:58 +00:00
|
|
|
if leader, e := s.topo.Leader(); e == nil {
|
2014-04-15 16:30:08 +00:00
|
|
|
ret.Leader = leader
|
2014-04-11 23:23:58 +00:00
|
|
|
}
|
2015-01-08 08:19:32 +00:00
|
|
|
writeJsonQuiet(w, r, http.StatusOK, ret)
|
2014-02-04 09:10:07 +00:00
|
|
|
}
|