diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-03-02 11:35:35 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-02 11:35:35 +0000 |
commit | 8996cc805913e9927f57cd3c4b8247a09a47472b (patch) | |
tree | 13820a28b1d71b4540bdc37e60878c706cc1df0c /mediaapi | |
parent | a4c918ee17d342e704aee738e4f0d5712b98eaa6 (diff) |
Media endpoints on `/v3` (#2242)
* Media endpoints on `/v3`
* Keep `/v1` too?
Diffstat (limited to 'mediaapi')
-rw-r--r-- | mediaapi/routing/routing.go | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/mediaapi/routing/routing.go b/mediaapi/routing/routing.go index 44f9a9d6..fc2136bb 100644 --- a/mediaapi/routing/routing.go +++ b/mediaapi/routing/routing.go @@ -53,8 +53,7 @@ func Setup( ) { rateLimits := httputil.NewRateLimits(rateLimit) - r0mux := publicAPIMux.PathPrefix("/r0").Subrouter() - v1mux := publicAPIMux.PathPrefix("/v1").Subrouter() + v3mux := publicAPIMux.PathPrefix("/{apiversion:(?:r0|v1|v3)}/").Subrouter() activeThumbnailGeneration := &types.ActiveThumbnailGeneration{ PathToResult: map[string]*types.ThumbnailGenerationResult{}, @@ -80,21 +79,18 @@ func Setup( } }) - r0mux.Handle("/upload", uploadHandler).Methods(http.MethodPost, http.MethodOptions) - r0mux.Handle("/config", configHandler).Methods(http.MethodGet, http.MethodOptions) - v1mux.Handle("/upload", uploadHandler).Methods(http.MethodPost, http.MethodOptions) + v3mux.Handle("/upload", uploadHandler).Methods(http.MethodPost, http.MethodOptions) + v3mux.Handle("/config", configHandler).Methods(http.MethodGet, http.MethodOptions) activeRemoteRequests := &types.ActiveRemoteRequests{ MXCToResult: map[string]*types.RemoteRequestResult{}, } downloadHandler := makeDownloadAPI("download", cfg, rateLimits, db, client, activeRemoteRequests, activeThumbnailGeneration) - r0mux.Handle("/download/{serverName}/{mediaId}", downloadHandler).Methods(http.MethodGet, http.MethodOptions) - r0mux.Handle("/download/{serverName}/{mediaId}/{downloadName}", downloadHandler).Methods(http.MethodGet, http.MethodOptions) - v1mux.Handle("/download/{serverName}/{mediaId}", downloadHandler).Methods(http.MethodGet, http.MethodOptions) // TODO: remove when synapse is fixed - v1mux.Handle("/download/{serverName}/{mediaId}/{downloadName}", downloadHandler).Methods(http.MethodGet, http.MethodOptions) // TODO: remove when synapse is fixed + v3mux.Handle("/download/{serverName}/{mediaId}", downloadHandler).Methods(http.MethodGet, http.MethodOptions) + v3mux.Handle("/download/{serverName}/{mediaId}/{downloadName}", downloadHandler).Methods(http.MethodGet, http.MethodOptions) - r0mux.Handle("/thumbnail/{serverName}/{mediaId}", + v3mux.Handle("/thumbnail/{serverName}/{mediaId}", makeDownloadAPI("thumbnail", cfg, rateLimits, db, client, activeRemoteRequests, activeThumbnailGeneration), ).Methods(http.MethodGet, http.MethodOptions) } |