mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-04-11 22:33:40 +00:00
HTTP API endpoints
This commit is contained in:
parent
90dd5e6544
commit
5ef94156f5
3 changed files with 38 additions and 0 deletions
|
@ -208,6 +208,16 @@ func (t *RoomserverInternalAPITrace) QueryStateAndAuthChain(
|
||||||
return err
|
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(
|
func (t *RoomserverInternalAPITrace) PerformBackfill(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *PerformBackfillRequest,
|
req *PerformBackfillRequest,
|
||||||
|
|
|
@ -47,6 +47,7 @@ const (
|
||||||
RoomserverQueryServerAllowedToSeeEventPath = "/roomserver/queryServerAllowedToSeeEvent"
|
RoomserverQueryServerAllowedToSeeEventPath = "/roomserver/queryServerAllowedToSeeEvent"
|
||||||
RoomserverQueryMissingEventsPath = "/roomserver/queryMissingEvents"
|
RoomserverQueryMissingEventsPath = "/roomserver/queryMissingEvents"
|
||||||
RoomserverQueryStateAndAuthChainPath = "/roomserver/queryStateAndAuthChain"
|
RoomserverQueryStateAndAuthChainPath = "/roomserver/queryStateAndAuthChain"
|
||||||
|
RoomserverQueryStateAndAuthChainIDsPath = "/roomserver/queryStateAndAuthChainIDs"
|
||||||
RoomserverQueryRoomVersionCapabilitiesPath = "/roomserver/queryRoomVersionCapabilities"
|
RoomserverQueryRoomVersionCapabilitiesPath = "/roomserver/queryRoomVersionCapabilities"
|
||||||
RoomserverQueryRoomVersionForRoomPath = "/roomserver/queryRoomVersionForRoom"
|
RoomserverQueryRoomVersionForRoomPath = "/roomserver/queryRoomVersionForRoom"
|
||||||
RoomserverQueryPublishedRoomsPath = "/roomserver/queryPublishedRooms"
|
RoomserverQueryPublishedRoomsPath = "/roomserver/queryPublishedRooms"
|
||||||
|
@ -417,6 +418,19 @@ func (h *httpRoomserverInternalAPI) QueryStateAndAuthChain(
|
||||||
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
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
|
// PerformBackfill implements RoomServerQueryAPI
|
||||||
func (h *httpRoomserverInternalAPI) PerformBackfill(
|
func (h *httpRoomserverInternalAPI) PerformBackfill(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
|
|
|
@ -261,6 +261,20 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
||||||
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
|
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(
|
internalAPIMux.Handle(
|
||||||
RoomserverPerformBackfillPath,
|
RoomserverPerformBackfillPath,
|
||||||
httputil.MakeInternalAPI("PerformBackfill", func(req *http.Request) util.JSONResponse {
|
httputil.MakeInternalAPI("PerformBackfill", func(req *http.Request) util.JSONResponse {
|
||||||
|
|
Loading…
Reference in a new issue