mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-14 05:12:26 +03:00
Add a query API to the roomserver for getting the latest events in a room. (#23)
* Start implementing a query API for go using net/rpc * Use a conventional JSON POST API rather than go net/rpc net/rpc doesn't automatically handle reconnecting and we have better logging and metrics infrastructure for monitoring HTTP apis. * Implement the query API and add it to the integration tests * Increase the timeout, travis seems to be a bit slow * Clarify that state events are the things that are not returned if they are not requested * Add utility function for converting arrays of numeric event IDs to pq Int64Arrays * Warn people against requesting empty state keys by accident
This commit is contained in:
parent
37e0b6c4c6
commit
9a8a8aedcb
12 changed files with 333 additions and 39 deletions
15
vendor/src/github.com/matrix-org/util/json.go
vendored
15
vendor/src/github.com/matrix-org/util/json.go
vendored
|
@ -58,6 +58,21 @@ type JSONRequestHandler interface {
|
|||
OnIncomingRequest(req *http.Request) JSONResponse
|
||||
}
|
||||
|
||||
// jsonRequestHandlerWrapper is a wrapper to allow in-line functions to conform to util.JSONRequestHandler
|
||||
type jsonRequestHandlerWrapper struct {
|
||||
function func(req *http.Request) JSONResponse
|
||||
}
|
||||
|
||||
// OnIncomingRequest implements util.JSONRequestHandler
|
||||
func (r *jsonRequestHandlerWrapper) OnIncomingRequest(req *http.Request) JSONResponse {
|
||||
return r.function(req)
|
||||
}
|
||||
|
||||
// NewJSONRequestHandler converts the given OnIncomingRequest function into a JSONRequestHandler
|
||||
func NewJSONRequestHandler(f func(req *http.Request) JSONResponse) JSONRequestHandler {
|
||||
return &jsonRequestHandlerWrapper{f}
|
||||
}
|
||||
|
||||
// Protect panicking HTTP requests from taking down the entire process, and log them using
|
||||
// the correct logger, returning a 500 with a JSON response rather than abruptly closing the
|
||||
// connection. The http.Request MUST have a ctxValueLogger.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue