aboutsummaryrefslogtreecommitdiff
path: root/mediaapi
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-06-16 14:29:11 +0100
committerGitHub <noreply@github.com>2020-06-16 14:29:11 +0100
commitfc0e74ae0f02b7bb9d71d739660deef824ddbd33 (patch)
treefd718a25749cc56e08412d565f5f1bf472156eb4 /mediaapi
parent9c77022513f400db59409f5b55fc6223d38d6bb8 (diff)
Fix media API for demos and possibly Synapse (#1134)
* Fix media API for demos and possibly Synapse * User API * goimports
Diffstat (limited to 'mediaapi')
-rw-r--r--mediaapi/mediaapi.go6
-rw-r--r--mediaapi/routing/routing.go10
2 files changed, 11 insertions, 5 deletions
diff --git a/mediaapi/mediaapi.go b/mediaapi/mediaapi.go
index 9219ba20..290ef46e 100644
--- a/mediaapi/mediaapi.go
+++ b/mediaapi/mediaapi.go
@@ -26,7 +26,9 @@ import (
// AddPublicRoutes sets up and registers HTTP handlers for the MediaAPI component.
func AddPublicRoutes(
- router *mux.Router, cfg *config.Dendrite, userAPI userapi.UserInternalAPI,
+ router *mux.Router, cfg *config.Dendrite,
+ userAPI userapi.UserInternalAPI,
+ client *gomatrixserverlib.Client,
) {
mediaDB, err := storage.Open(string(cfg.Database.MediaAPI), cfg.DbProperties())
if err != nil {
@@ -34,6 +36,6 @@ func AddPublicRoutes(
}
routing.Setup(
- router, cfg, mediaDB, userAPI, gomatrixserverlib.NewClient(),
+ router, cfg, mediaDB, userAPI, client,
)
}
diff --git a/mediaapi/routing/routing.go b/mediaapi/routing/routing.go
index 71804606..13f84c33 100644
--- a/mediaapi/routing/routing.go
+++ b/mediaapi/routing/routing.go
@@ -32,6 +32,7 @@ import (
)
const pathPrefixR0 = "/media/r0"
+const pathPrefixV1 = "/media/v1" // TODO: remove when synapse is fixed
// Setup registers the media API HTTP handlers
//
@@ -46,6 +47,7 @@ func Setup(
client *gomatrixserverlib.Client,
) {
r0mux := publicAPIMux.PathPrefix(pathPrefixR0).Subrouter()
+ v1mux := publicAPIMux.PathPrefix(pathPrefixV1).Subrouter()
activeThumbnailGeneration := &types.ActiveThumbnailGeneration{
PathToResult: map[string]*types.ThumbnailGenerationResult{},
@@ -60,9 +62,11 @@ func Setup(
activeRemoteRequests := &types.ActiveRemoteRequests{
MXCToResult: map[string]*types.RemoteRequestResult{},
}
- r0mux.Handle("/download/{serverName}/{mediaId}",
- makeDownloadAPI("download", cfg, db, client, activeRemoteRequests, activeThumbnailGeneration),
- ).Methods(http.MethodGet, http.MethodOptions)
+
+ downloadHandler := makeDownloadAPI("download", cfg, db, client, activeRemoteRequests, activeThumbnailGeneration)
+ r0mux.Handle("/download/{serverName}/{mediaId}", downloadHandler).Methods(http.MethodGet, http.MethodOptions)
+ v1mux.Handle("/download/{serverName}/{mediaId}", downloadHandler).Methods(http.MethodGet, http.MethodOptions) // TODO: remove when synapse is fixed
+
r0mux.Handle("/thumbnail/{serverName}/{mediaId}",
makeDownloadAPI("thumbnail", cfg, db, client, activeRemoteRequests, activeThumbnailGeneration),
).Methods(http.MethodGet, http.MethodOptions)