From 2b9cf56f565517b947b0eb71d2086764e9edf2be Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Thu, 23 Nov 2023 19:10:51 +0100 Subject: [chore/bugfix] Fix double gzip on prometheus endpoint (#2383) * [chore] Move "/metrics" into separate API module * use our own gzip middleware for prom --- cmd/gotosocial/action/server/server.go | 2 ++ cmd/gotosocial/action/testrig/testrig.go | 2 ++ 2 files changed, 4 insertions(+) (limited to 'cmd') diff --git a/cmd/gotosocial/action/server/server.go b/cmd/gotosocial/action/server/server.go index a9896a81c..3a8965f1e 100644 --- a/cmd/gotosocial/action/server/server.go +++ b/cmd/gotosocial/action/server/server.go @@ -293,6 +293,7 @@ var Start action.GTSAction = func(ctx context.Context) error { var ( authModule = api.NewAuth(dbService, processor, idp, routerSession, sessionName) // auth/oauth paths clientModule = api.NewClient(dbService, processor) // api client endpoints + metricsModule = api.NewMetrics() // Metrics endpoints fileserverModule = api.NewFileserver(processor) // fileserver endpoints wellKnownModule = api.NewWellKnown(processor) // .well-known endpoints nodeInfoModule = api.NewNodeInfo(processor) // nodeinfo endpoint @@ -322,6 +323,7 @@ var Start action.GTSAction = func(ctx context.Context) error { // apply throttling *after* rate limiting authModule.Route(router, clLimit, clThrottle, gzip) clientModule.Route(router, clLimit, clThrottle, gzip) + metricsModule.Route(router, clLimit, clThrottle, gzip) fileserverModule.Route(router, fsLimit, fsThrottle) wellKnownModule.Route(router, gzip, s2sLimit, s2sThrottle) nodeInfoModule.Route(router, s2sLimit, s2sThrottle, gzip) diff --git a/cmd/gotosocial/action/testrig/testrig.go b/cmd/gotosocial/action/testrig/testrig.go index f08bec609..d6bc92215 100644 --- a/cmd/gotosocial/action/testrig/testrig.go +++ b/cmd/gotosocial/action/testrig/testrig.go @@ -212,6 +212,7 @@ var Start action.GTSAction = func(ctx context.Context) error { var ( authModule = api.NewAuth(state.DB, processor, idp, routerSession, sessionName) // auth/oauth paths clientModule = api.NewClient(state.DB, processor) // api client endpoints + metricsModule = api.NewMetrics() // Metrics endpoints fileserverModule = api.NewFileserver(processor) // fileserver endpoints wellKnownModule = api.NewWellKnown(processor) // .well-known endpoints nodeInfoModule = api.NewNodeInfo(processor) // nodeinfo endpoint @@ -222,6 +223,7 @@ var Start action.GTSAction = func(ctx context.Context) error { // these should be routed in order authModule.Route(router) clientModule.Route(router) + metricsModule.Route(router) fileserverModule.Route(router) wellKnownModule.Route(router) nodeInfoModule.Route(router) -- cgit v1.2.3