From e715a440d755affccbc7e51c2c84af064d49f1f7 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 20 Feb 2017 15:30:05 +0000 Subject: [PATCH] Just call straight through --- .../matrix-org/dendrite/clientapi/readers/sync.go | 7 ++----- .../matrix-org/dendrite/clientapi/routing/routing.go | 7 ++++--- .../matrix-org/dendrite/clientapi/writers/sendmessage.go | 8 ++------ 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/clientapi/readers/sync.go b/src/github.com/matrix-org/dendrite/clientapi/readers/sync.go index f83c34954..27a470945 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/readers/sync.go +++ b/src/github.com/matrix-org/dendrite/clientapi/readers/sync.go @@ -6,11 +6,8 @@ import ( "github.com/matrix-org/util" ) -// Sync handles HTTP requests to /sync -type Sync struct{} - -// OnIncomingRequest implements util.JSONRequestHandler -func (s *Sync) OnIncomingRequest(req *http.Request) (interface{}, *util.HTTPError) { +// Sync implements /sync +func Sync(req *http.Request) (interface{}, *util.HTTPError) { logger := util.GetLogger(req.Context()) logger.Info("Doing stuff...") return nil, &util.HTTPError{ diff --git a/src/github.com/matrix-org/dendrite/clientapi/routing/routing.go b/src/github.com/matrix-org/dendrite/clientapi/routing/routing.go index e993276e8..beebc30b4 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/routing/routing.go +++ b/src/github.com/matrix-org/dendrite/clientapi/routing/routing.go @@ -17,14 +17,15 @@ const pathPrefixR0 = "/_matrix/client/r0" func Setup(servMux *http.ServeMux, httpClient *http.Client) { apiMux := mux.NewRouter() 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}", make("send_message", wrap(func(req *http.Request) (interface{}, *util.HTTPError) { vars := mux.Vars(req) roomID := vars["roomID"] eventType := vars["eventType"] - h := &writers.SendMessage{} - return h.OnIncomingRequest(req, roomID, eventType) + return writers.SendMessage(req, roomID, eventType) })), ) diff --git a/src/github.com/matrix-org/dendrite/clientapi/writers/sendmessage.go b/src/github.com/matrix-org/dendrite/clientapi/writers/sendmessage.go index c3dec7855..11b17740d 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/writers/sendmessage.go +++ b/src/github.com/matrix-org/dendrite/clientapi/writers/sendmessage.go @@ -6,12 +6,8 @@ import ( "github.com/matrix-org/util" ) -// SendMessage handles HTTP requests to /rooms/$room_id/send/$event_type -type SendMessage struct { -} - -// OnIncomingRequest implements /rooms/{roomID}/send/{eventType} -func (s *SendMessage) OnIncomingRequest(req *http.Request, roomID, eventType string) (interface{}, *util.HTTPError) { +// SendMessage implements /rooms/{roomID}/send/{eventType} +func SendMessage(req *http.Request, roomID, eventType string) (interface{}, *util.HTTPError) { logger := util.GetLogger(req.Context()) logger.WithField("roomID", roomID).WithField("eventType", eventType).Info("Doing stuff...") return nil, &util.HTTPError{