mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-28 17:23:09 -06:00
Rewrite URL
This commit is contained in:
parent
7b5e47f81a
commit
71e2ae7421
|
|
@ -117,7 +117,10 @@ func Setup(
|
||||||
|
|
||||||
r0mux := publicAPIMux.PathPrefix("/r0").Subrouter()
|
r0mux := publicAPIMux.PathPrefix("/r0").Subrouter()
|
||||||
unstableMux := publicAPIMux.PathPrefix("/unstable").Subrouter()
|
unstableMux := publicAPIMux.PathPrefix("/unstable").Subrouter()
|
||||||
unstableMux.NotFoundHandler = r0mux // serve r0 endpoints by default unless overridden
|
defer unstableMux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
r.URL.Path = strings.Replace(r.URL.Path, "/unstable/", "/r0/", 1)
|
||||||
|
r0mux.ServeHTTP(w, r)
|
||||||
|
}) // serve r0 endpoints by default unless overridden
|
||||||
|
|
||||||
r0mux.Handle("/createRoom",
|
r0mux.Handle("/createRoom",
|
||||||
httputil.MakeAuthAPI("createRoom", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {
|
httputil.MakeAuthAPI("createRoom", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {
|
||||||
|
|
|
||||||
|
|
@ -57,12 +57,6 @@ func Setup(
|
||||||
v1fedmux := fedMux.PathPrefix("/v1").Subrouter()
|
v1fedmux := fedMux.PathPrefix("/v1").Subrouter()
|
||||||
v2fedmux := fedMux.PathPrefix("/v2").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{
|
wakeup := &httputil.FederationWakeups{
|
||||||
FsAPI: fsAPI,
|
FsAPI: fsAPI,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ package routing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/matrix-org/dendrite/internal/httputil"
|
"github.com/matrix-org/dendrite/internal/httputil"
|
||||||
|
|
@ -41,7 +42,10 @@ func Setup(
|
||||||
) {
|
) {
|
||||||
r0mux := csMux.PathPrefix("/r0").Subrouter()
|
r0mux := csMux.PathPrefix("/r0").Subrouter()
|
||||||
unstableMux := csMux.PathPrefix("/unstable").Subrouter()
|
unstableMux := csMux.PathPrefix("/unstable").Subrouter()
|
||||||
unstableMux.NotFoundHandler = r0mux // serve r0 endpoints by default unless overridden
|
defer unstableMux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
r.URL.Path = strings.Replace(r.URL.Path, "/unstable/", "/r0/", 1)
|
||||||
|
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