mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-29 12:42:46 +00:00
Fix media API for demos and possibly Synapse (#1134)
* Fix media API for demos and possibly Synapse * User API * goimports
This commit is contained in:
parent
9c77022513
commit
fc0e74ae0f
9 changed files with 71 additions and 25 deletions
|
@ -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,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue