diff options
author | Kegsay <kegan@matrix.org> | 2020-06-08 15:51:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-08 15:51:07 +0100 |
commit | 4f171c56a832c836b0eb21650ee84d56e451dd6a (patch) | |
tree | e92059f1dbb784c978b60897d6ac13983d51c1b4 /eduserver | |
parent | cdb9a115715bd5a9e84df5bc95060e2dac1f6d89 (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 'eduserver')
-rw-r--r-- | eduserver/eduserver.go | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/eduserver/eduserver.go b/eduserver/eduserver.go index 59decc8f..c14be3f6 100644 --- a/eduserver/eduserver.go +++ b/eduserver/eduserver.go @@ -17,6 +17,7 @@ package eduserver import ( + "github.com/gorilla/mux" "github.com/matrix-org/dendrite/clientapi/auth/storage/devices" "github.com/matrix-org/dendrite/eduserver/api" "github.com/matrix-org/dendrite/eduserver/cache" @@ -25,16 +26,20 @@ import ( "github.com/matrix-org/dendrite/internal/basecomponent" ) -// SetupEDUServerComponent sets up and registers HTTP handlers for the -// EDUServer 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 SetupEDUServerComponent( +// AddInternalRoutes registers HTTP handlers for the internal API. Invokes functions +// on the given input API. +func AddInternalRoutes(internalMux *mux.Router, inputAPI api.EDUServerInputAPI) { + inthttp.AddRoutes(inputAPI, internalMux) +} + +// 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, eduCache *cache.EDUCache, deviceDB devices.Database, ) api.EDUServerInputAPI { - inputAPI := &input.EDUServerInputAPI{ + return &input.EDUServerInputAPI{ Cache: eduCache, DeviceDB: deviceDB, Producer: base.KafkaProducer, @@ -42,8 +47,4 @@ func SetupEDUServerComponent( OutputSendToDeviceEventTopic: string(base.Cfg.Kafka.Topics.OutputSendToDeviceEvent), ServerName: base.Cfg.Matrix.ServerName, } - - inthttp.AddRoutes(inputAPI, base.InternalAPIMux) - - return inputAPI } |