Default /unstable requests to stable endpoints if not overridden specifically with a custom route

This commit is contained in:
Neil Alexander 2021-07-27 19:40:30 +01:00
parent 32bf14a37c
commit 7b5e47f81a
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
3 changed files with 9 additions and 0 deletions

View file

@ -117,6 +117,7 @@ func Setup(
r0mux := publicAPIMux.PathPrefix("/r0").Subrouter()
unstableMux := publicAPIMux.PathPrefix("/unstable").Subrouter()
unstableMux.NotFoundHandler = r0mux // serve r0 endpoints by default unless overridden
r0mux.Handle("/createRoom",
httputil.MakeAuthAPI("createRoom", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {

View file

@ -57,6 +57,12 @@ func Setup(
v1fedmux := fedMux.PathPrefix("/v1").Subrouter()
v2fedmux := fedMux.PathPrefix("/v2").Subrouter()
unstableFedMux := fedMux.PathPrefix("/unstable").Subrouter()
unstableFedMux.NotFoundHandler = v2fedmux // serve v2 endpoints by default unless overridden
unstableKeysMux := keyMux.PathPrefix("/unstable").Subrouter()
unstableKeysMux.NotFoundHandler = v2keysmux // serve v2 endpoints by default unless overridden
wakeup := &httputil.FederationWakeups{
FsAPI: fsAPI,
}

View file

@ -40,6 +40,8 @@ func Setup(
cfg *config.SyncAPI,
) {
r0mux := csMux.PathPrefix("/r0").Subrouter()
unstableMux := csMux.PathPrefix("/unstable").Subrouter()
unstableMux.NotFoundHandler = r0mux // serve r0 endpoints by default unless overridden
// TODO: Add AS support for all handlers below.
r0mux.Handle("/sync", httputil.MakeAuthAPI("sync", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {