Skip to content
This repository has been archived by the owner on May 17, 2022. It is now read-only.

Commit

Permalink
Now configurable, and API will not respond if disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Buhr committed Dec 11, 2014
1 parent c41e32f commit 533b5d7
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -782,25 +782,30 @@ func healthCheckhandler(w http.ResponseWriter, r *http.Request) {
var code int = 200

if r.Method == "GET" {
APIID := r.FormValue("api_id")
if APIID == "" {
code = 405
responseMessage = createError("missing api_id parameter")
} else {
thisAPISpec := GetSpecForApi(APIID)
if thisAPISpec != nil {
health, _ := thisAPISpec.Health.GetApiHealthValues()
var jsonErr error
responseMessage, jsonErr = json.Marshal(health)
if jsonErr != nil {
if config.HealthCheck.EnableHealthChecks {
APIID := r.FormValue("api_id")
if APIID == "" {
code = 405
responseMessage = createError("missing api_id parameter")
} else {
thisAPISpec := GetSpecForApi(APIID)
if thisAPISpec != nil {
health, _ := thisAPISpec.Health.GetApiHealthValues()
var jsonErr error
responseMessage, jsonErr = json.Marshal(health)
if jsonErr != nil {
code = 405
responseMessage = createError("Failed to encode data")
}
} else {
code = 405
responseMessage = createError("Failed to encode data")
responseMessage = createError("API ID not found")
}
} else {
code = 405
responseMessage = createError("API ID not found")
}

}
} else {
code = 405
responseMessage = createError("Health checks are not enabled for this node")
}
} else {
// Return Not supported message (and code)
Expand Down

0 comments on commit 533b5d7

Please sign in to comment.