mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-16 19:33:09 -06:00
45 lines
1.4 KiB
Go
45 lines
1.4 KiB
Go
// Copyright 2020 The Matrix.org Foundation C.I.C.
|
|
//
|
|
// 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.
|
|
|
|
package query
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"github.com/matrix-org/dendrite/common"
|
|
"github.com/matrix-org/dendrite/roomserver/api"
|
|
"github.com/matrix-org/dendrite/syncapi/sync"
|
|
"github.com/matrix-org/util"
|
|
)
|
|
|
|
type SyncQueryAPI struct {
|
|
requestPool sync.RequestPool
|
|
}
|
|
|
|
// SetupHTTP adds the RoomserverQueryAPI handlers to the http.ServeMux.
|
|
// nolint: gocyclo
|
|
func (s *SyncQueryAPI) SetupHTTP(servMux *http.ServeMux) {
|
|
servMux.Handle(
|
|
api.RoomserverQueryLatestEventsAndStatePath,
|
|
common.MakeInternalAPI("querySync", func(req *http.Request) util.JSONResponse {
|
|
var request api.QuerySyncRequest
|
|
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
|
return util.ErrorResponse(err)
|
|
}
|
|
return s.OnIncomingSyncRequest()
|
|
}),
|
|
)
|
|
}
|