From 3f9f4ecd2492345dcd3f9089cf1a14ef2ba3d7f1 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Wed, 13 Aug 2025 15:12:50 +0200 Subject: [PATCH] fix: remove double-gzip-encoding from metrics endpoint fixes #217 Signed-off-by: Knut Ahlers --- main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 376854a..e5f07fa 100644 --- a/main.go +++ b/main.go @@ -126,7 +126,7 @@ func main() { api.Register(r.PathPrefix("/api").Subrouter()) - r.Handle("/metrics", metrics.Handler()). + r.Handle("/metrics", handleRemoveAcceptEncoding(metrics.Handler())). Methods(http.MethodGet). MatcherFunc(func(r *http.Request, _ *mux.RouteMatch) bool { return requestInSubnetList(r, cust.MetricsAllowedSubnets) @@ -240,3 +240,10 @@ func handleIndex(w http.ResponseWriter, _ *http.Request) { return } } + +func handleRemoveAcceptEncoding(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + r.Header.Del("Accept-Encoding") + next.ServeHTTP(w, r) + }) +}