mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-14 21:32:23 +03:00
Define path prefixes in a package that doesn't create import cycles
This commit is contained in:
parent
06d5f1e6dc
commit
3c3e014901
4 changed files with 23 additions and 9 deletions
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/matrix-org/dendrite/clientapi/auth"
|
||||
"github.com/matrix-org/dendrite/clientapi/auth/authtypes"
|
||||
"github.com/matrix-org/dendrite/internal/config"
|
||||
"github.com/matrix-org/dendrite/internal/httpapis"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
"github.com/matrix-org/util"
|
||||
opentracing "github.com/opentracing/opentracing-go"
|
||||
|
@ -23,11 +24,6 @@ import (
|
|||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const (
|
||||
HTTPPublicPathPrefix = "/_matrix/"
|
||||
HTTPInternalPathPrefix = "/api/"
|
||||
)
|
||||
|
||||
// BasicAuth is used for authorization on /metrics handlers
|
||||
type BasicAuth struct {
|
||||
Username string `yaml:"username"`
|
||||
|
@ -195,9 +191,9 @@ func SetupHTTPAPI(servMux *http.ServeMux, publicApiMux *mux.Router, internalApiM
|
|||
servMux.Handle("/metrics", WrapHandlerInBasicAuth(promhttp.Handler(), cfg.Metrics.BasicAuth))
|
||||
}
|
||||
if enableHTTPAPIs {
|
||||
servMux.Handle(HTTPInternalPathPrefix, internalApiMux)
|
||||
servMux.Handle(httpapis.InternalPathPrefix, internalApiMux)
|
||||
}
|
||||
servMux.Handle(HTTPPublicPathPrefix, WrapHandlerInCORS(publicApiMux))
|
||||
servMux.Handle(httpapis.PublicPathPrefix, WrapHandlerInCORS(publicApiMux))
|
||||
}
|
||||
|
||||
// WrapHandlerInBasicAuth adds basic auth to a handler. Only used for /metrics
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue