From 0a3d2fdf0ddc2c0810e953b799697a85f00b6317 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 26 May 2020 15:53:25 +0100 Subject: [PATCH] Route server key API endpoints on internal API mux --- serverkeyapi/internal/http.go | 7 ++++--- serverkeyapi/serverkeyapi.go | 6 +----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/serverkeyapi/internal/http.go b/serverkeyapi/internal/http.go index 2f6d4b52e..b6b6bf8d2 100644 --- a/serverkeyapi/internal/http.go +++ b/serverkeyapi/internal/http.go @@ -4,14 +4,15 @@ import ( "encoding/json" "net/http" + "github.com/gorilla/mux" "github.com/matrix-org/dendrite/internal" "github.com/matrix-org/dendrite/serverkeyapi/api" "github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/util" ) -func (s *ServerKeyAPI) SetupHTTP(servMux *http.ServeMux) { - servMux.Handle(api.ServerKeyQueryPublicKeyPath, +func (s *ServerKeyAPI) SetupHTTP(internalAPIMux *mux.Router) { + internalAPIMux.Handle(api.ServerKeyQueryPublicKeyPath, internal.MakeInternalAPI("queryPublicKeys", func(req *http.Request) util.JSONResponse { result := map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.PublicKeyLookupResult{} request := api.QueryPublicKeysRequest{} @@ -38,7 +39,7 @@ func (s *ServerKeyAPI) SetupHTTP(servMux *http.ServeMux) { return util.JSONResponse{Code: http.StatusOK, JSON: &response} }), ) - servMux.Handle(api.ServerKeyInputPublicKeyPath, + internalAPIMux.Handle(api.ServerKeyInputPublicKeyPath, internal.MakeInternalAPI("inputPublicKeys", func(req *http.Request) util.JSONResponse { request := api.InputPublicKeysRequest{} response := api.InputPublicKeysResponse{} diff --git a/serverkeyapi/serverkeyapi.go b/serverkeyapi/serverkeyapi.go index 3d189ba39..1601970a9 100644 --- a/serverkeyapi/serverkeyapi.go +++ b/serverkeyapi/serverkeyapi.go @@ -79,11 +79,7 @@ func SetupServerKeyAPIComponent( }).Info("Enabled perspective key fetcher") } - /* - if base.EnableHTTPAPIs { - internalAPI.SetupHTTP(http.DefaultServeMux) - } - */ + internalAPI.SetupHTTP(base.InternalAPIMux) return &internalAPI }