From 40eb7cbeef8d8e70e7751defe11521b1d27202ac Mon Sep 17 00:00:00 2001 From: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Date: Mon, 17 Jun 2024 10:25:41 +0200 Subject: [PATCH] Use httputil.Routers for the media API --- mediaapi/mediaapi.go | 6 +++--- mediaapi/routing/routing.go | 4 ++-- setup/monolith.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mediaapi/mediaapi.go b/mediaapi/mediaapi.go index 3425fbce6..4eb45b3d1 100644 --- a/mediaapi/mediaapi.go +++ b/mediaapi/mediaapi.go @@ -15,7 +15,7 @@ package mediaapi import ( - "github.com/gorilla/mux" + "github.com/matrix-org/dendrite/internal/httputil" "github.com/matrix-org/dendrite/internal/sqlutil" "github.com/matrix-org/dendrite/mediaapi/routing" "github.com/matrix-org/dendrite/mediaapi/storage" @@ -27,7 +27,7 @@ import ( // AddPublicRoutes sets up and registers HTTP handlers for the MediaAPI component. func AddPublicRoutes( - mediaRouter *mux.Router, + routers httputil.Routers, cm *sqlutil.Connections, cfg *config.Dendrite, userAPI userapi.MediaUserAPI, @@ -39,6 +39,6 @@ func AddPublicRoutes( } routing.Setup( - mediaRouter, cfg, mediaDB, userAPI, client, + routers, cfg, mediaDB, userAPI, client, ) } diff --git a/mediaapi/routing/routing.go b/mediaapi/routing/routing.go index 5963eeaae..4edb5ab2c 100644 --- a/mediaapi/routing/routing.go +++ b/mediaapi/routing/routing.go @@ -45,7 +45,7 @@ type configResponse struct { // applied: // nolint: gocyclo func Setup( - publicAPIMux *mux.Router, + routers httputil.Routers, cfg *config.Dendrite, db storage.Database, userAPI userapi.MediaUserAPI, @@ -53,7 +53,7 @@ func Setup( ) { rateLimits := httputil.NewRateLimits(&cfg.ClientAPI.RateLimiting) - v3mux := publicAPIMux.PathPrefix("/{apiversion:(?:r0|v1|v3)}/").Subrouter() + v3mux := routers.Media.PathPrefix("/{apiversion:(?:r0|v1|v3)}/").Subrouter() activeThumbnailGeneration := &types.ActiveThumbnailGeneration{ PathToResult: map[string]*types.ThumbnailGenerationResult{}, diff --git a/setup/monolith.go b/setup/monolith.go index 4856d6e83..64a447acb 100644 --- a/setup/monolith.go +++ b/setup/monolith.go @@ -78,7 +78,7 @@ func (m *Monolith) AddAllPublicRoutes( federationapi.AddPublicRoutes( processCtx, routers, cfg, natsInstance, m.UserAPI, m.FedClient, m.KeyRing, m.RoomserverAPI, m.FederationAPI, enableMetrics, ) - mediaapi.AddPublicRoutes(routers.Media, cm, cfg, m.UserAPI, m.Client) + mediaapi.AddPublicRoutes(routers, cm, cfg, m.UserAPI, m.Client) syncapi.AddPublicRoutes(processCtx, routers, cfg, cm, natsInstance, m.UserAPI, m.RoomserverAPI, caches, enableMetrics) if m.RelayAPI != nil {