Support verbose query param in ping endpoint of influxdb_listener (#5704)

This commit is contained in:
Greg 2019-04-11 14:15:38 -06:00 committed by Daniel Nelson
parent 24391a8b5e
commit 776e06c769
1 changed files with 10 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import (
"compress/gzip"
"crypto/subtle"
"crypto/tls"
"encoding/json"
"fmt"
"io"
"log"
@ -231,8 +232,16 @@ func (h *HTTPListener) ServeHTTP(res http.ResponseWriter, req *http.Request) {
case "/ping":
h.PingsRecv.Incr(1)
defer h.PingsServed.Incr(1)
verbose := req.URL.Query().Get("verbose")
// respond to ping requests
res.WriteHeader(http.StatusNoContent)
if verbose != "" && verbose != "0" && verbose != "false" {
res.WriteHeader(http.StatusOK)
b, _ := json.Marshal(map[string]string{"version": "1.0"}) // based on header set above
res.Write(b)
} else {
res.WriteHeader(http.StatusNoContent)
}
default:
defer h.NotFoundsServed.Incr(1)
// Don't know how to respond to calls to other endpoints