mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-29 01:33:10 -06:00
Try something different
This commit is contained in:
parent
71e2ae7421
commit
02699bf704
|
|
@ -29,6 +29,13 @@ import (
|
||||||
"github.com/matrix-org/util"
|
"github.com/matrix-org/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func unstableDefaultMiddleware(next http.Handler) http.Handler {
|
||||||
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
r.URL.Path = strings.Replace(r.URL.Path, "/unstable/", "/r0/", 1)
|
||||||
|
next.ServeHTTP(w, r)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Setup configures the given mux with sync-server listeners
|
// Setup configures the given mux with sync-server listeners
|
||||||
//
|
//
|
||||||
// Due to Setup being used to call many other functions, a gocyclo nolint is
|
// Due to Setup being used to call many other functions, a gocyclo nolint is
|
||||||
|
|
@ -42,10 +49,8 @@ func Setup(
|
||||||
) {
|
) {
|
||||||
r0mux := csMux.PathPrefix("/r0").Subrouter()
|
r0mux := csMux.PathPrefix("/r0").Subrouter()
|
||||||
unstableMux := csMux.PathPrefix("/unstable").Subrouter()
|
unstableMux := csMux.PathPrefix("/unstable").Subrouter()
|
||||||
defer unstableMux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
unstableMux.NotFoundHandler = r0mux
|
||||||
r.URL.Path = strings.Replace(r.URL.Path, "/unstable/", "/r0/", 1)
|
unstableMux.Use(unstableDefaultMiddleware)
|
||||||
r0mux.ServeHTTP(w, r)
|
|
||||||
}) // serve r0 endpoints by default unless overridden
|
|
||||||
|
|
||||||
// TODO: Add AS support for all handlers below.
|
// TODO: Add AS support for all handlers below.
|
||||||
r0mux.Handle("/sync", httputil.MakeAuthAPI("sync", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {
|
r0mux.Handle("/sync", httputil.MakeAuthAPI("sync", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue