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