Separate muxes for public and internal APIs (#1056)

* Separate muxes for public and internal APIs

* Update client-api-proxy and federation-api-proxy so they don't add /api to the path

* Tidy up

* Consistent HTTP setup

* Set up prefixes properly
This commit is contained in:
Neil Alexander 2020-05-22 11:43:17 +01:00 committed by GitHub
parent f223da2f35
commit fe82e1f725
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 131 additions and 119 deletions

View file

@ -44,7 +44,7 @@ func SetupFederationAPIComponent(
roomserverProducer := producers.NewRoomserverProducer(rsAPI)
routing.Setup(
base.APIMux, base.Cfg, rsAPI, asAPI, roomserverProducer,
base.PublicAPIMux, base.Cfg, rsAPI, asAPI, roomserverProducer,
eduProducer, federationSenderAPI, *keyRing,
federation, accountsDB, deviceDB,
)

View file

@ -31,9 +31,9 @@ import (
)
const (
pathPrefixV2Keys = "/_matrix/key/v2"
pathPrefixV1Federation = "/_matrix/federation/v1"
pathPrefixV2Federation = "/_matrix/federation/v2"
pathPrefixV2Keys = "/key/v2"
pathPrefixV1Federation = "/federation/v1"
pathPrefixV2Federation = "/federation/v2"
)
// Setup registers HTTP handlers with the given ServeMux.
@ -42,7 +42,7 @@ const (
// applied:
// nolint: gocyclo
func Setup(
apiMux *mux.Router,
publicAPIMux *mux.Router,
cfg *config.Dendrite,
rsAPI roomserverAPI.RoomserverInternalAPI,
asAPI appserviceAPI.AppServiceQueryAPI,
@ -54,9 +54,9 @@ func Setup(
accountDB accounts.Database,
deviceDB devices.Database,
) {
v2keysmux := apiMux.PathPrefix(pathPrefixV2Keys).Subrouter()
v1fedmux := apiMux.PathPrefix(pathPrefixV1Federation).Subrouter()
v2fedmux := apiMux.PathPrefix(pathPrefixV2Federation).Subrouter()
v2keysmux := publicAPIMux.PathPrefix(pathPrefixV2Keys).Subrouter()
v1fedmux := publicAPIMux.PathPrefix(pathPrefixV1Federation).Subrouter()
v2fedmux := publicAPIMux.PathPrefix(pathPrefixV2Federation).Subrouter()
localKeys := internal.MakeExternalAPI("localkeys", func(req *http.Request) util.JSONResponse {
return LocalKeys(cfg)