2013-12-23 19:38:51 +00:00
|
|
|
package agent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2019-07-25 18:26:22 +00:00
|
|
|
|
|
|
|
"github.com/hashicorp/consul/agent/structs"
|
2013-12-23 19:38:51 +00:00
|
|
|
)
|
|
|
|
|
2020-09-04 18:42:15 +00:00
|
|
|
func (s *HTTPHandlers) StatusLeader(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
2019-07-25 18:26:22 +00:00
|
|
|
args := structs.DCSpecificRequest{}
|
|
|
|
if done := s.parse(resp, req, &args.Datacenter, &args.QueryOptions); done {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2013-12-23 19:38:51 +00:00
|
|
|
var out string
|
2019-07-25 18:26:22 +00:00
|
|
|
if err := s.agent.RPC("Status.Leader", &args, &out); err != nil {
|
2013-12-23 19:38:51 +00:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return out, nil
|
|
|
|
}
|
|
|
|
|
2020-09-04 18:42:15 +00:00
|
|
|
func (s *HTTPHandlers) StatusPeers(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
2019-07-25 18:26:22 +00:00
|
|
|
args := structs.DCSpecificRequest{}
|
|
|
|
if done := s.parse(resp, req, &args.Datacenter, &args.QueryOptions); done {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2013-12-23 19:38:51 +00:00
|
|
|
var out []string
|
2019-07-25 18:26:22 +00:00
|
|
|
if err := s.agent.RPC("Status.Peers", &args, &out); err != nil {
|
2013-12-23 19:38:51 +00:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return out, nil
|
|
|
|
}
|