@@ -292,6 +292,16 @@ var (
292292 requireMetadataPath = requestPathCond {path : promapi .APIPathMetadata }
293293)
294294
295+ type httpResponse struct {
296+ body string
297+ code int
298+ }
299+
300+ func (hr httpResponse ) respond (w http.ResponseWriter , _ * http.Request ) {
301+ w .WriteHeader (hr .code )
302+ _ , _ = w .Write ([]byte (hr .body ))
303+ }
304+
295305type promError struct {
296306 errorType v1.ErrorType
297307 err string
@@ -323,7 +333,7 @@ type vectorResponse struct {
323333}
324334
325335func (vr vectorResponse ) respond (w http.ResponseWriter , _ * http.Request ) {
326- w .WriteHeader (200 )
336+ w .WriteHeader (http . StatusOK )
327337 w .Header ().Set ("Content-Type" , "application/json" )
328338 result := struct {
329339 Status string `json:"status"`
@@ -376,7 +386,7 @@ func (mr matrixResponse) respond(w http.ResponseWriter, r *http.Request) {
376386 }
377387 }
378388
379- w .WriteHeader (200 )
389+ w .WriteHeader (http . StatusOK )
380390 w .Header ().Set ("Content-Type" , "application/json" )
381391 result := struct {
382392 Status string `json:"status"`
@@ -409,7 +419,7 @@ type configResponse struct {
409419}
410420
411421func (cr configResponse ) respond (w http.ResponseWriter , _ * http.Request ) {
412- w .WriteHeader (200 )
422+ w .WriteHeader (http . StatusOK )
413423 w .Header ().Set ("Content-Type" , "application/json" )
414424 result := struct {
415425 Status string `json:"status"`
@@ -430,7 +440,7 @@ type flagsResponse struct {
430440}
431441
432442func (fg flagsResponse ) respond (w http.ResponseWriter , _ * http.Request ) {
433- w .WriteHeader (200 )
443+ w .WriteHeader (http . StatusOK )
434444 w .Header ().Set ("Content-Type" , "application/json" )
435445 result := struct {
436446 Data v1.FlagsResult `json:"data"`
@@ -451,7 +461,7 @@ type metadataResponse struct {
451461}
452462
453463func (mr metadataResponse ) respond (w http.ResponseWriter , _ * http.Request ) {
454- w .WriteHeader (200 )
464+ w .WriteHeader (http . StatusOK )
455465 w .Header ().Set ("Content-Type" , "application/json" )
456466 // _, _ = w.Write([]byte(`{"status":"success","data":{"gauge":[{"type":"gauge","help":"Text","unit":""}]}}`))
457467 result := struct {
@@ -586,3 +596,7 @@ func checkErrorUnableToRun(c, name, uri, err string) string {
586596func checkErrorTooExpensiveToRun (c , name , uri , err string ) string {
587597 return fmt .Sprintf ("Couldn't run %q checks on `%s` Prometheus server at %s because some queries are too expensive: `%s`." , c , name , uri , err )
588598}
599+
600+ func checkUnsupported (c , name , uri , path string ) string {
601+ return fmt .Sprintf ("Couldn't run %q checks on `%s` Prometheus server at %s because it's unsupported: this server doesn't seem to support `%s` API endpoint." , c , name , uri , path )
602+ }
0 commit comments