fix: remove double-gzip-encoding from metrics endpoint

fixes #217

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2025-08-13 15:12:50 +02:00
parent 3ceba030dc
commit 3f9f4ecd24
No known key found for this signature in database

View file

@ -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)
})
}