From ac14d25e4706410e1f66feb316fe6c5020fb6a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Juan=20G=C3=B3mez=20Pe=C3=B1alver?= Date: Wed, 23 Apr 2025 11:56:44 +0100 Subject: [PATCH] fix: Use Prometheus standard content-type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Juan Gómez Peñalver --- serve.go | 4 ++++ serve_test.go | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/serve.go b/serve.go index d30973ad..858973c7 100644 --- a/serve.go +++ b/serve.go @@ -186,5 +186,9 @@ func (h healthHandler) responseContentType(outputName string) string { if outputName == "json" { return "application/json" } + if outputName == "prometheus" { + return "text/plain; version=0.0.4" + } + return fmt.Sprintf("%s%s", mediaTypePrefix, outputName) } diff --git a/serve_test.go b/serve_test.go index 8b19d048..c7f64a26 100644 --- a/serve_test.go +++ b/serve_test.go @@ -117,6 +117,15 @@ func TestServeNegotiatingContent(t *testing.T) { expectedHTTPStatus: http.StatusOK, expectedContentType: "application/json", }, + "accept prometheus": { + acceptHeader: []string{ + "text/plain; version=0.0.4", + }, + outputFormat: "prometheus", + specFile: filepath.Join("testdata", "passing.goss.yaml"), + expectedHTTPStatus: http.StatusOK, + expectedContentType: "text/plain; version=0.0.4", + }, "accept header contains vendor-specific output format different from process-level": { acceptHeader: []string{ "application/vnd.goss-rspecish",