aboutsummaryrefslogtreecommitdiff
path: root/roomserver/roomserver.go
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-06-08 15:51:07 +0100
committerGitHub <noreply@github.com>2020-06-08 15:51:07 +0100
commit4f171c56a832c836b0eb21650ee84d56e451dd6a (patch)
treee92059f1dbb784c978b60897d6ac13983d51c1b4 /roomserver/roomserver.go
parentcdb9a115715bd5a9e84df5bc95060e2dac1f6d89 (diff)
Split out SetupFooComponent (#1106)
* Split out adding HTTP routes from making internal APIs for clarity * Split out more components * Split out more things * Finish converting * internal mux for internal routes
Diffstat (limited to 'roomserver/roomserver.go')
-rw-r--r--roomserver/roomserver.go21
1 files changed, 11 insertions, 10 deletions
diff --git a/roomserver/roomserver.go b/roomserver/roomserver.go
index a55b20be..a9db22d7 100644
--- a/roomserver/roomserver.go
+++ b/roomserver/roomserver.go
@@ -15,6 +15,7 @@
package roomserver
import (
+ "github.com/gorilla/mux"
"github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/dendrite/roomserver/inthttp"
"github.com/matrix-org/gomatrixserverlib"
@@ -25,11 +26,15 @@ import (
"github.com/sirupsen/logrus"
)
-// SetupRoomServerComponent sets up and registers HTTP handlers for the
-// RoomServer component. Returns instances of the various roomserver APIs,
-// allowing other components running in the same process to hit the query the
-// APIs directly instead of having to use HTTP.
-func SetupRoomServerComponent(
+// AddInternalRoutes registers HTTP handlers for the internal API. Invokes functions
+// on the given input API.
+func AddInternalRoutes(router *mux.Router, intAPI api.RoomserverInternalAPI) {
+ inthttp.AddRoutes(intAPI, router)
+}
+
+// NewInternalAPI returns a concerete implementation of the internal API. Callers
+// can call functions directly on the returned API or via an HTTP interface using AddInternalRoutes.
+func NewInternalAPI(
base *basecomponent.BaseDendrite,
keyRing gomatrixserverlib.JSONVerifier,
fedClient *gomatrixserverlib.FederationClient,
@@ -39,7 +44,7 @@ func SetupRoomServerComponent(
logrus.WithError(err).Panicf("failed to connect to room server db")
}
- internalAPI := &internal.RoomserverInternalAPI{
+ return &internal.RoomserverInternalAPI{
DB: roomserverDB,
Cfg: base.Cfg,
Producer: base.KafkaProducer,
@@ -49,8 +54,4 @@ func SetupRoomServerComponent(
FedClient: fedClient,
KeyRing: keyRing,
}
-
- inthttp.AddRoutes(internalAPI, base.InternalAPIMux)
-
- return internalAPI
}