aboutsummaryrefslogtreecommitdiff
path: root/internal/httputil
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 /internal/httputil
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 'internal/httputil')
-rw-r--r--internal/httputil/httpapi.go12
-rw-r--r--internal/httputil/paths.go7
2 files changed, 5 insertions, 14 deletions
diff --git a/internal/httputil/httpapi.go b/internal/httputil/httpapi.go
index 8f7723ef..c69468e6 100644
--- a/internal/httputil/httpapi.go
+++ b/internal/httputil/httpapi.go
@@ -28,7 +28,6 @@ import (
"github.com/gorilla/mux"
"github.com/matrix-org/dendrite/clientapi/auth"
federationsenderAPI "github.com/matrix-org/dendrite/federationsender/api"
- "github.com/matrix-org/dendrite/internal/config"
userapi "github.com/matrix-org/dendrite/userapi/api"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util"
@@ -233,17 +232,6 @@ func (f *FederationWakeups) Wakeup(ctx context.Context, origin gomatrixserverlib
}
}
-// SetupHTTPAPI registers an HTTP API mux under /api and sets up a metrics listener
-func SetupHTTPAPI(servMux, publicApiMux, internalApiMux *mux.Router, cfg *config.Global, enableHTTPAPIs bool) {
- if cfg.Metrics.Enabled {
- servMux.Handle("/metrics", WrapHandlerInBasicAuth(promhttp.Handler(), cfg.Metrics.BasicAuth))
- }
- if enableHTTPAPIs {
- servMux.Handle(InternalPathPrefix, internalApiMux)
- }
- servMux.Handle(PublicPathPrefix, WrapHandlerInCORS(publicApiMux))
-}
-
// WrapHandlerInBasicAuth adds basic auth to a handler. Only used for /metrics
func WrapHandlerInBasicAuth(h http.Handler, b BasicAuth) http.HandlerFunc {
if b.Username == "" || b.Password == "" {
diff --git a/internal/httputil/paths.go b/internal/httputil/paths.go
index 728b5a87..b0f4b8cb 100644
--- a/internal/httputil/paths.go
+++ b/internal/httputil/paths.go
@@ -15,6 +15,9 @@
package httputil
const (
- PublicPathPrefix = "/_matrix/"
- InternalPathPrefix = "/api/"
+ PublicClientPathPrefix = "/_matrix/client/"
+ PublicFederationPathPrefix = "/_matrix/federation/"
+ PublicKeyPathPrefix = "/_matrix/key/"
+ PublicMediaPathPrefix = "/_matrix/media/"
+ InternalPathPrefix = "/api/"
)