aboutsummaryrefslogtreecommitdiff
path: root/clientapi
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-08-13 12:16:37 +0100
committerGitHub <noreply@github.com>2020-08-13 12:16:37 +0100
commit9677a95afc529d1766d487db46965266c6fbaa6a (patch)
treed98ccf518a3f8386054f93be4138988def9848be /clientapi
parent820c56c165ec8f0409d23cd151a7ff89fbe09ffa (diff)
API setup refactoring (#1266)
* Start HTTP endpoint refactoring * Update SetupAndServeHTTP * Fix builds * Don't set up external listener if no address configured * TLS HTTP setup * Break apart client/federation/key/media muxes * Tweaks * Fix P2P demos * Fix media API routing * Review comments @Kegsay * Update sample config * Fix gobind build * Fix External -> Public in federation API test
Diffstat (limited to 'clientapi')
-rw-r--r--clientapi/routing/routing.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go
index 883b473b..d40621ec 100644
--- a/clientapi/routing/routing.go
+++ b/clientapi/routing/routing.go
@@ -40,10 +40,6 @@ import (
"github.com/matrix-org/util"
)
-const pathPrefixV1 = "/client/api/v1"
-const pathPrefixR0 = "/client/r0"
-const pathPrefixUnstable = "/client/unstable"
-
// Setup registers HTTP handlers with the given ServeMux. It also supplies the given http.Client
// to clients which need to make outbound HTTP requests.
//
@@ -68,7 +64,7 @@ func Setup(
) {
userInteractiveAuth := auth.NewUserInteractive(accountDB.GetAccountByPassword, cfg)
- publicAPIMux.Handle("/client/versions",
+ publicAPIMux.Handle("/versions",
httputil.MakeExternalAPI("versions", func(req *http.Request) util.JSONResponse {
return util.JSONResponse{
Code: http.StatusOK,
@@ -84,9 +80,9 @@ func Setup(
}),
).Methods(http.MethodGet, http.MethodOptions)
- r0mux := publicAPIMux.PathPrefix(pathPrefixR0).Subrouter()
- v1mux := publicAPIMux.PathPrefix(pathPrefixV1).Subrouter()
- unstableMux := publicAPIMux.PathPrefix(pathPrefixUnstable).Subrouter()
+ r0mux := publicAPIMux.PathPrefix("/r0").Subrouter()
+ v1mux := publicAPIMux.PathPrefix("/api/v1").Subrouter()
+ unstableMux := publicAPIMux.PathPrefix("/unstable").Subrouter()
r0mux.Handle("/createRoom",
httputil.MakeAuthAPI("createRoom", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {