Changes /ping route to return status code 200 instead of 204 when verbose is set

Closes #9772.
pull/10321/head
Ryan Coleman 2018-10-01 16:43:23 -05:00 committed by Jonathan A. Sternberg
parent 677552f093
commit 76fe3f081c
No known key found for this signature in database
GPG Key ID: 4A0C1200CB8B9D2E
1 changed files with 9 additions and 1 deletions

View File

@ -817,8 +817,16 @@ func (h *Handler) serveOptions(w http.ResponseWriter, r *http.Request) {
// servePing returns a simple response to let the client know the server is running.
func (h *Handler) servePing(w http.ResponseWriter, r *http.Request) {
verbose := r.URL.Query().Get("verbose")
atomic.AddInt64(&h.stats.PingRequests, 1)
if verbose != "" && verbose != "0" && verbose != "false" {
h.writeHeader(w, http.StatusOK)
b, _ := json.Marshal(map[string]string{"version": h.Version})
w.Write(b)
} else {
h.writeHeader(w, http.StatusNoContent)
}
}
// serveStatus has been deprecated.