2018-07-24 16:49:49 +02: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 16:02:20 +02:00
|
|
|
package eduserver
|
2018-07-24 16:49:49 +02:00
|
|
|
|
|
|
|
import (
|
2018-08-02 19:22:44 +02:00
|
|
|
"net/http"
|
|
|
|
|
2020-03-30 16:02:20 +02:00
|
|
|
"github.com/matrix-org/dendrite/eduserver/api"
|
|
|
|
"github.com/matrix-org/dendrite/eduserver/cache"
|
|
|
|
"github.com/matrix-org/dendrite/eduserver/input"
|
2020-05-21 15:40:13 +02:00
|
|
|
"github.com/matrix-org/dendrite/internal/basecomponent"
|
2018-07-24 16:49:49 +02:00
|
|
|
)
|
|
|
|
|
2020-03-30 16:02:20 +02:00
|
|
|
// SetupEDUServerComponent sets up and registers HTTP handlers for the
|
|
|
|
// EDUServer component. Returns instances of the various roomserver APIs,
|
2018-07-24 16:49:49 +02: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 16:02:20 +02:00
|
|
|
func SetupEDUServerComponent(
|
2018-07-24 16:49:49 +02:00
|
|
|
base *basecomponent.BaseDendrite,
|
2020-03-30 16:02:20 +02:00
|
|
|
eduCache *cache.EDUCache,
|
|
|
|
) api.EDUServerInputAPI {
|
|
|
|
inputAPI := &input.EDUServerInputAPI{
|
|
|
|
Cache: eduCache,
|
2018-08-02 19:22:44 +02:00
|
|
|
Producer: base.KafkaProducer,
|
|
|
|
OutputTypingEventTopic: string(base.Cfg.Kafka.Topics.OutputTypingEvent),
|
|
|
|
}
|
|
|
|
|
2020-05-18 11:56:43 +02:00
|
|
|
if base.EnableHTTPAPIs {
|
|
|
|
inputAPI.SetupHTTP(http.DefaultServeMux)
|
|
|
|
}
|
|
|
|
|
2018-08-02 19:22:44 +02:00
|
|
|
return inputAPI
|
2018-07-24 16:49:49 +02:00
|
|
|
}
|