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