mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-07 15:03:09 -06:00
Just call straight through
This commit is contained in:
parent
e96b5103a1
commit
e715a440d7
|
|
@ -6,11 +6,8 @@ import (
|
||||||
"github.com/matrix-org/util"
|
"github.com/matrix-org/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Sync handles HTTP requests to /sync
|
// Sync implements /sync
|
||||||
type Sync struct{}
|
func Sync(req *http.Request) (interface{}, *util.HTTPError) {
|
||||||
|
|
||||||
// OnIncomingRequest implements util.JSONRequestHandler
|
|
||||||
func (s *Sync) OnIncomingRequest(req *http.Request) (interface{}, *util.HTTPError) {
|
|
||||||
logger := util.GetLogger(req.Context())
|
logger := util.GetLogger(req.Context())
|
||||||
logger.Info("Doing stuff...")
|
logger.Info("Doing stuff...")
|
||||||
return nil, &util.HTTPError{
|
return nil, &util.HTTPError{
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,15 @@ const pathPrefixR0 = "/_matrix/client/r0"
|
||||||
func Setup(servMux *http.ServeMux, httpClient *http.Client) {
|
func Setup(servMux *http.ServeMux, httpClient *http.Client) {
|
||||||
apiMux := mux.NewRouter()
|
apiMux := mux.NewRouter()
|
||||||
r0mux := apiMux.PathPrefix(pathPrefixR0).Subrouter()
|
r0mux := apiMux.PathPrefix(pathPrefixR0).Subrouter()
|
||||||
r0mux.Handle("/sync", make("sync", &readers.Sync{}))
|
r0mux.Handle("/sync", make("sync", wrap(func(req *http.Request) (interface{}, *util.HTTPError) {
|
||||||
|
return readers.Sync(req)
|
||||||
|
})))
|
||||||
r0mux.Handle("/rooms/{roomID}/send/{eventType}",
|
r0mux.Handle("/rooms/{roomID}/send/{eventType}",
|
||||||
make("send_message", wrap(func(req *http.Request) (interface{}, *util.HTTPError) {
|
make("send_message", wrap(func(req *http.Request) (interface{}, *util.HTTPError) {
|
||||||
vars := mux.Vars(req)
|
vars := mux.Vars(req)
|
||||||
roomID := vars["roomID"]
|
roomID := vars["roomID"]
|
||||||
eventType := vars["eventType"]
|
eventType := vars["eventType"]
|
||||||
h := &writers.SendMessage{}
|
return writers.SendMessage(req, roomID, eventType)
|
||||||
return h.OnIncomingRequest(req, roomID, eventType)
|
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,8 @@ import (
|
||||||
"github.com/matrix-org/util"
|
"github.com/matrix-org/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SendMessage handles HTTP requests to /rooms/$room_id/send/$event_type
|
// SendMessage implements /rooms/{roomID}/send/{eventType}
|
||||||
type SendMessage struct {
|
func SendMessage(req *http.Request, roomID, eventType string) (interface{}, *util.HTTPError) {
|
||||||
}
|
|
||||||
|
|
||||||
// OnIncomingRequest implements /rooms/{roomID}/send/{eventType}
|
|
||||||
func (s *SendMessage) OnIncomingRequest(req *http.Request, roomID, eventType string) (interface{}, *util.HTTPError) {
|
|
||||||
logger := util.GetLogger(req.Context())
|
logger := util.GetLogger(req.Context())
|
||||||
logger.WithField("roomID", roomID).WithField("eventType", eventType).Info("Doing stuff...")
|
logger.WithField("roomID", roomID).WithField("eventType", eventType).Info("Doing stuff...")
|
||||||
return nil, &util.HTTPError{
|
return nil, &util.HTTPError{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue