Use Content-Type to specify protocol and version.
This commit is contained in:
parent
a087e013a5
commit
4321769f6d
|
@ -28,9 +28,9 @@ const (
|
||||||
APIVersion = "0.0.1"
|
APIVersion = "0.0.1"
|
||||||
|
|
||||||
// When reporting telemetric data over the HTTP web services interface, a web
|
// When reporting telemetric data over the HTTP web services interface, a web
|
||||||
// services interface shall include this header along with APIVersion as its
|
// services interface shall include this Content-Type along with APIVersion as its
|
||||||
// value.
|
// value.
|
||||||
ProtocolVersionHeader = "X-Prometheus-API-Version"
|
ProtocolContentType = "Content-Type: application/json; protocol=prometheus_telemetry; version=" + APIVersion
|
||||||
|
|
||||||
// The customary web services endpoint on which telemetric data is exposed.
|
// The customary web services endpoint on which telemetric data is exposed.
|
||||||
ExpositionResource = "/metrics.json"
|
ExpositionResource = "/metrics.json"
|
||||||
|
|
|
@ -31,7 +31,6 @@ const (
|
||||||
contentTypeHeader = "Content-Type"
|
contentTypeHeader = "Content-Type"
|
||||||
gzipAcceptEncodingValue = "gzip"
|
gzipAcceptEncodingValue = "gzip"
|
||||||
gzipContentEncodingValue = "gzip"
|
gzipContentEncodingValue = "gzip"
|
||||||
jsonContentType = "application/json"
|
|
||||||
jsonSuffix = ".json"
|
jsonSuffix = ".json"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -277,8 +276,7 @@ func (registry registry) Handler() http.HandlerFunc {
|
||||||
|
|
||||||
if strings.HasSuffix(url.Path, jsonSuffix) {
|
if strings.HasSuffix(url.Path, jsonSuffix) {
|
||||||
header := w.Header()
|
header := w.Header()
|
||||||
header.Set(ProtocolVersionHeader, APIVersion)
|
header.Set(contentTypeHeader, ProtocolContentType)
|
||||||
header.Set(contentTypeHeader, jsonContentType)
|
|
||||||
|
|
||||||
writer := decorateWriter(r, w)
|
writer := decorateWriter(r, w)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue