2018-07-24 15:49:49 +01:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2020-03-30 15:02:20 +01:00
|
|
|
package eduserver
|
2018-07-24 15:49:49 +01:00
|
|
|
|
|
|
|
import (
|
2018-08-02 18:22:44 +01:00
|
|
|
"net/http"
|
|
|
|
|
2018-07-24 15:49:49 +01:00
|
|
|
"github.com/matrix-org/dendrite/common/basecomponent"
|
2020-03-30 15:02:20 +01:00
|
|
|
"github.com/matrix-org/dendrite/eduserver/api"
|
|
|
|
"github.com/matrix-org/dendrite/eduserver/cache"
|
|
|
|
"github.com/matrix-org/dendrite/eduserver/input"
|
2018-07-24 15:49:49 +01:00
|
|
|
)
|
|
|
|
|
2020-03-30 15:02:20 +01:00
|
|
|
// SetupEDUServerComponent sets up and registers HTTP handlers for the
|
|
|
|
// EDUServer component. Returns instances of the various roomserver APIs,
|
2018-07-24 15:49:49 +01:00
|
|
|
// allowing other components running in the same process to hit the query the
|
|
|
|
// APIs directly instead of having to use HTTP.
|
2020-03-30 15:02:20 +01:00
|
|
|
func SetupEDUServerComponent(
|
2018-07-24 15:49:49 +01:00
|
|
|
base *basecomponent.BaseDendrite,
|
2020-03-30 15:02:20 +01:00
|
|
|
eduCache *cache.EDUCache,
|
|
|
|
) api.EDUServerInputAPI {
|
|
|
|
inputAPI := &input.EDUServerInputAPI{
|
|
|
|
Cache: eduCache,
|
2018-08-02 18:22:44 +01:00
|
|
|
Producer: base.KafkaProducer,
|
|
|
|
OutputTypingEventTopic: string(base.Cfg.Kafka.Topics.OutputTypingEvent),
|
|
|
|
}
|
|
|
|
|
2020-05-18 10:56:43 +01:00
|
|
|
if base.EnableHTTPAPIs {
|
|
|
|
inputAPI.SetupHTTP(http.DefaultServeMux)
|
|
|
|
}
|
|
|
|
|
2018-08-02 18:22:44 +01:00
|
|
|
return inputAPI
|
2018-07-24 15:49:49 +01:00
|
|
|
}
|