From dbded875257703eb63c8eb8af8d47d74c811642f Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 18 Feb 2022 14:14:16 +0000 Subject: [PATCH] Expose sync endpoints via `/v3` (#2203) --- syncapi/routing/routing.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/syncapi/routing/routing.go b/syncapi/routing/routing.go index e2ff27395..005a33555 100644 --- a/syncapi/routing/routing.go +++ b/syncapi/routing/routing.go @@ -39,14 +39,14 @@ func Setup( rsAPI api.RoomserverInternalAPI, cfg *config.SyncAPI, ) { - r0mux := csMux.PathPrefix("/r0").Subrouter() + v3mux := csMux.PathPrefix("/{apiversion:(?:r0|v3)}/").Subrouter() // TODO: Add AS support for all handlers below. - r0mux.Handle("/sync", httputil.MakeAuthAPI("sync", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse { + v3mux.Handle("/sync", httputil.MakeAuthAPI("sync", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse { return srp.OnIncomingSyncRequest(req, device) })).Methods(http.MethodGet, http.MethodOptions) - r0mux.Handle("/rooms/{roomID}/messages", httputil.MakeAuthAPI("room_messages", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse { + v3mux.Handle("/rooms/{roomID}/messages", httputil.MakeAuthAPI("room_messages", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse { vars, err := httputil.URLDecodeMapValues(mux.Vars(req)) if err != nil { return util.ErrorResponse(err) @@ -54,7 +54,7 @@ func Setup( return OnIncomingMessagesRequest(req, syncDB, vars["roomID"], device, federation, rsAPI, cfg, srp) })).Methods(http.MethodGet, http.MethodOptions) - r0mux.Handle("/user/{userId}/filter", + v3mux.Handle("/user/{userId}/filter", httputil.MakeAuthAPI("put_filter", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse { vars, err := httputil.URLDecodeMapValues(mux.Vars(req)) if err != nil { @@ -64,7 +64,7 @@ func Setup( }), ).Methods(http.MethodPost, http.MethodOptions) - r0mux.Handle("/user/{userId}/filter/{filterId}", + v3mux.Handle("/user/{userId}/filter/{filterId}", httputil.MakeAuthAPI("get_filter", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse { vars, err := httputil.URLDecodeMapValues(mux.Vars(req)) if err != nil { @@ -74,7 +74,7 @@ func Setup( }), ).Methods(http.MethodGet, http.MethodOptions) - r0mux.Handle("/keys/changes", httputil.MakeAuthAPI("keys_changes", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse { + v3mux.Handle("/keys/changes", httputil.MakeAuthAPI("keys_changes", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse { return srp.OnIncomingKeyChangeRequest(req, device) })).Methods(http.MethodGet, http.MethodOptions) }