This commit is contained in:
Neil Alexander 2020-08-13 10:59:57 +01:00
parent 89ab97be74
commit 6fc1cd2179
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
8 changed files with 15 additions and 30 deletions

View file

@ -184,7 +184,7 @@ func (m *DendriteMonolith) Start() {
httpRouter.PathPrefix(httputil.ExternalMediaPathPrefix).Handler(base.ExternalMediaAPIMux)
yggRouter := mux.NewRouter()
httpRouter.PathPrefix(httputil.ExternalFederationPathPrefix).Handler(base.ExternalClientAPIMux)
httpRouter.PathPrefix(httputil.ExternalFederationPathPrefix).Handler(base.ExternalFederationAPIMux)
httpRouter.PathPrefix(httputil.ExternalMediaPathPrefix).Handler(base.ExternalMediaAPIMux)
// Build both ends of a HTTP multiplex.

View file

@ -40,10 +40,6 @@ import (
"github.com/matrix-org/util"
)
const pathPrefixV1 = "/api/v1"
const pathPrefixR0 = "/r0"
const pathPrefixUnstable = "/unstable"
// Setup registers HTTP handlers with the given ServeMux. It also supplies the given http.Client
// to clients which need to make outbound HTTP requests.
//
@ -84,9 +80,9 @@ func Setup(
}),
).Methods(http.MethodGet, http.MethodOptions)
r0mux := publicAPIMux.PathPrefix(pathPrefixR0).Subrouter()
v1mux := publicAPIMux.PathPrefix(pathPrefixV1).Subrouter()
unstableMux := publicAPIMux.PathPrefix(pathPrefixUnstable).Subrouter()
r0mux := publicAPIMux.PathPrefix("/r0").Subrouter()
v1mux := publicAPIMux.PathPrefix("/api/v1").Subrouter()
unstableMux := publicAPIMux.PathPrefix("/unstable").Subrouter()
r0mux.Handle("/createRoom",
httputil.MakeAuthAPI("createRoom", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {

View file

@ -204,8 +204,8 @@ func main() {
httpRouter.PathPrefix(httputil.ExternalMediaPathPrefix).Handler(base.Base.ExternalMediaAPIMux)
libp2pRouter := mux.NewRouter()
httpRouter.PathPrefix(httputil.ExternalFederationPathPrefix).Handler(base.Base.ExternalClientAPIMux)
httpRouter.PathPrefix(httputil.ExternalKeyPathPrefix).Handler(base.Base.ExternalClientAPIMux)
httpRouter.PathPrefix(httputil.ExternalFederationPathPrefix).Handler(base.Base.ExternalFederationAPIMux)
httpRouter.PathPrefix(httputil.ExternalKeyPathPrefix).Handler(base.Base.ExternalKeyAPIMux)
httpRouter.PathPrefix(httputil.ExternalMediaPathPrefix).Handler(base.Base.ExternalMediaAPIMux)
// Expose the matrix APIs directly rather than putting them under a /api path.

View file

@ -169,7 +169,7 @@ func main() {
httpRouter.PathPrefix(httputil.ExternalMediaPathPrefix).Handler(base.ExternalMediaAPIMux)
yggRouter := mux.NewRouter()
httpRouter.PathPrefix(httputil.ExternalFederationPathPrefix).Handler(base.ExternalClientAPIMux)
httpRouter.PathPrefix(httputil.ExternalFederationPathPrefix).Handler(base.ExternalFederationAPIMux)
httpRouter.PathPrefix(httputil.ExternalMediaPathPrefix).Handler(base.ExternalMediaAPIMux)
// Build both ends of a HTTP multiplex.

View file

@ -248,7 +248,7 @@ func main() {
httpRouter.PathPrefix(httputil.ExternalMediaPathPrefix).Handler(base.ExternalMediaAPIMux)
libp2pRouter := mux.NewRouter()
httpRouter.PathPrefix(httputil.ExternalFederationPathPrefix).Handler(base.ExternalClientAPIMux)
httpRouter.PathPrefix(httputil.ExternalFederationPathPrefix).Handler(base.ExternalFederationAPIMux)
httpRouter.PathPrefix(httputil.ExternalMediaPathPrefix).Handler(base.ExternalMediaAPIMux)
// Expose the matrix APIs via libp2p-js - for federation traffic

View file

@ -31,12 +31,6 @@ import (
"github.com/matrix-org/util"
)
const (
pathPrefixV2Keys = "/v2"
pathPrefixV1Federation = "/v1"
pathPrefixV2Federation = "/v2"
)
// Setup registers HTTP handlers with the given ServeMux.
// The provided publicAPIMux MUST have `UseEncodedPath()` enabled or else routes will incorrectly
// path unescape twice (once from the router, once from MakeFedAPI). We need to have this enabled
@ -57,9 +51,9 @@ func Setup(
stateAPI currentstateAPI.CurrentStateInternalAPI,
keyAPI keyserverAPI.KeyInternalAPI,
) {
v2keysmux := keyMux.PathPrefix(pathPrefixV2Keys).Subrouter()
v1fedmux := fedMux.PathPrefix(pathPrefixV1Federation).Subrouter()
v2fedmux := fedMux.PathPrefix(pathPrefixV2Federation).Subrouter()
v2keysmux := keyMux.PathPrefix("/v2").Subrouter()
v1fedmux := fedMux.PathPrefix("/v1").Subrouter()
v2fedmux := fedMux.PathPrefix("/v2").Subrouter()
wakeup := &httputil.FederationWakeups{
FsAPI: fsAPI,

View file

@ -32,9 +32,6 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
)
const pathPrefixR0 = "/media/r0"
const pathPrefixV1 = "/media/v1" // TODO: remove when synapse is fixed
// Setup registers the media API HTTP handlers
//
// Due to Setup being used to call many other functions, a gocyclo nolint is
@ -47,8 +44,8 @@ func Setup(
userAPI userapi.UserInternalAPI,
client *gomatrixserverlib.Client,
) {
r0mux := publicAPIMux.PathPrefix(pathPrefixR0).Subrouter()
v1mux := publicAPIMux.PathPrefix(pathPrefixV1).Subrouter()
r0mux := publicAPIMux.PathPrefix("/media/r0").Subrouter()
v1mux := publicAPIMux.PathPrefix("/media/v1").Subrouter()
activeThumbnailGeneration := &types.ActiveThumbnailGeneration{
PathToResult: map[string]*types.ThumbnailGenerationResult{},

View file

@ -28,20 +28,18 @@ import (
"github.com/matrix-org/util"
)
const pathPrefixR0 = "/client/r0"
// Setup configures the given mux with sync-server listeners
//
// Due to Setup being used to call many other functions, a gocyclo nolint is
// applied:
// nolint: gocyclo
func Setup(
publicAPIMux *mux.Router, srp *sync.RequestPool, syncDB storage.Database,
csMux *mux.Router, srp *sync.RequestPool, syncDB storage.Database,
userAPI userapi.UserInternalAPI, federation *gomatrixserverlib.FederationClient,
rsAPI api.RoomserverInternalAPI,
cfg *config.SyncAPI,
) {
r0mux := publicAPIMux.PathPrefix(pathPrefixR0).Subrouter()
r0mux := csMux.PathPrefix("/r0").Subrouter()
// TODO: Add AS support for all handlers below.
r0mux.Handle("/sync", httputil.MakeAuthAPI("sync", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {