HTTP API endpoints

This commit is contained in:
Neil Alexander 2021-07-15 15:13:42 +01:00
parent 90dd5e6544
commit 5ef94156f5
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
3 changed files with 38 additions and 0 deletions

View file

@ -208,6 +208,16 @@ func (t *RoomserverInternalAPITrace) QueryStateAndAuthChain(
return err
}
func (t *RoomserverInternalAPITrace) QueryStateAndAuthChainIDs(
ctx context.Context,
req *QueryStateAndAuthChainIDsRequest,
res *QueryStateAndAuthChainIDsResponse,
) error {
err := t.Impl.QueryStateAndAuthChainIDs(ctx, req, res)
util.GetLogger(ctx).WithError(err).Infof("QueryStateAndAuthChainIDs req=%+v res=%+v", js(req), js(res))
return err
}
func (t *RoomserverInternalAPITrace) PerformBackfill(
ctx context.Context,
req *PerformBackfillRequest,

View file

@ -47,6 +47,7 @@ const (
RoomserverQueryServerAllowedToSeeEventPath = "/roomserver/queryServerAllowedToSeeEvent"
RoomserverQueryMissingEventsPath = "/roomserver/queryMissingEvents"
RoomserverQueryStateAndAuthChainPath = "/roomserver/queryStateAndAuthChain"
RoomserverQueryStateAndAuthChainIDsPath = "/roomserver/queryStateAndAuthChainIDs"
RoomserverQueryRoomVersionCapabilitiesPath = "/roomserver/queryRoomVersionCapabilities"
RoomserverQueryRoomVersionForRoomPath = "/roomserver/queryRoomVersionForRoom"
RoomserverQueryPublishedRoomsPath = "/roomserver/queryPublishedRooms"
@ -417,6 +418,19 @@ func (h *httpRoomserverInternalAPI) QueryStateAndAuthChain(
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// QueryStateAndAuthChainIDs implements RoomserverQueryAPI
func (h *httpRoomserverInternalAPI) QueryStateAndAuthChainIDs(
ctx context.Context,
request *api.QueryStateAndAuthChainIDsRequest,
response *api.QueryStateAndAuthChainIDsResponse,
) error {
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryStateAndAuthChainIDs")
defer span.Finish()
apiURL := h.roomserverURL + RoomserverQueryStateAndAuthChainIDsPath
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// PerformBackfill implements RoomServerQueryAPI
func (h *httpRoomserverInternalAPI) PerformBackfill(
ctx context.Context,

View file

@ -261,6 +261,20 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
}),
)
internalAPIMux.Handle(
RoomserverQueryStateAndAuthChainIDsPath,
httputil.MakeInternalAPI("queryStateAndAuthChainIDs", func(req *http.Request) util.JSONResponse {
var request api.QueryStateAndAuthChainIDsRequest
var response api.QueryStateAndAuthChainIDsResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
return util.ErrorResponse(err)
}
if err := r.QueryStateAndAuthChainIDs(req.Context(), &request, &response); err != nil {
return util.ErrorResponse(err)
}
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
}),
)
internalAPIMux.Handle(
RoomserverPerformBackfillPath,
httputil.MakeInternalAPI("PerformBackfill", func(req *http.Request) util.JSONResponse {