mirror of https://github.com/status-im/consul.git
Installs a friendly handler for coordinate endpoints when coordinates are disabled.
This commit is contained in:
parent
ce0e9759f8
commit
d45fc23abf
|
@ -5,6 +5,14 @@ import (
|
|||
"net/http"
|
||||
)
|
||||
|
||||
// coordinateDisabled handles all the endpoints when coordinates are not enabled,
|
||||
// returning an error message.
|
||||
func coordinateDisabled(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
||||
resp.WriteHeader(401)
|
||||
resp.Write([]byte("Coordinate support disabled"))
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// CoordinateDatacenters returns the WAN nodes in each datacenter, along with
|
||||
// raw network coordinates.
|
||||
func (s *HTTPServer) CoordinateDatacenters(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
||||
|
|
|
@ -209,6 +209,9 @@ func (s *HTTPServer) registerHandlers(enableDebug bool) {
|
|||
if !s.agent.config.DisableCoordinates {
|
||||
s.mux.HandleFunc("/v1/coordinate/datacenters", s.wrap(s.CoordinateDatacenters))
|
||||
s.mux.HandleFunc("/v1/coordinate/nodes", s.wrap(s.CoordinateNodes))
|
||||
} else {
|
||||
s.mux.HandleFunc("/v1/coordinate/datacenters", s.wrap(coordinateDisabled))
|
||||
s.mux.HandleFunc("/v1/coordinate/nodes", s.wrap(coordinateDisabled))
|
||||
}
|
||||
|
||||
s.mux.HandleFunc("/v1/health/node/", s.wrap(s.HealthNodeChecks))
|
||||
|
|
Loading…
Reference in New Issue