2023-03-28 18:39:22 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-03-28 18:39:22 +00:00
|
|
|
|
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
|
2022-12-14 15:24:22 +00:00
|
|
|
if err := s.agent.RPC(req.Context(), "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
|
2022-12-14 15:24:22 +00:00
|
|
|
if err := s.agent.RPC(req.Context(), "Status.Peers", &args, &out); err != nil {
|
2013-12-23 19:38:51 +00:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return out, nil
|
|
|
|
}
|