mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-21 05:43:09 -06:00
Tidy up
This commit is contained in:
parent
5199cb5cee
commit
a7ac34dad6
|
|
@ -178,13 +178,10 @@ func main() {
|
||||||
publicroomsapi.SetupPublicRoomsAPIComponent(&base.Base, deviceDB, publicRoomsDB, rsAPI, federation, nil) // Check this later
|
publicroomsapi.SetupPublicRoomsAPIComponent(&base.Base, deviceDB, publicRoomsDB, rsAPI, federation, nil) // Check this later
|
||||||
syncapi.SetupSyncAPIComponent(&base.Base, deviceDB, accountDB, rsAPI, federation, &cfg)
|
syncapi.SetupSyncAPIComponent(&base.Base, deviceDB, accountDB, rsAPI, federation, &cfg)
|
||||||
|
|
||||||
httpHandler := internal.WrapHandlerInCORS(base.Base.PublicAPIMux)
|
|
||||||
|
|
||||||
// Set up the API endpoints we handle. /metrics is for prometheus, and is
|
// Set up the API endpoints we handle. /metrics is for prometheus, and is
|
||||||
// not wrapped by CORS, while everything else is
|
// not wrapped by CORS, while everything else is
|
||||||
http.Handle("/metrics", promhttp.Handler())
|
http.Handle("/metrics", promhttp.Handler())
|
||||||
http.Handle("/_matrix", httpHandler)
|
http.Handle("/_matrix", internal.WrapHandlerInCORS(base.Base.PublicAPIMux))
|
||||||
http.Handle("/_matrix", httpHandler)
|
|
||||||
if base.Base.EnableHTTPAPIs {
|
if base.Base.EnableHTTPAPIs {
|
||||||
http.Handle("/api/", base.Base.InternalAPIMux)
|
http.Handle("/api/", base.Base.InternalAPIMux)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,14 +91,12 @@ func main() {
|
||||||
publicroomsapi.SetupPublicRoomsAPIComponent(base, deviceDB, publicRoomsDB, rsAPI, federation, nil)
|
publicroomsapi.SetupPublicRoomsAPIComponent(base, deviceDB, publicRoomsDB, rsAPI, federation, nil)
|
||||||
syncapi.SetupSyncAPIComponent(base, deviceDB, accountDB, rsAPI, federation, cfg)
|
syncapi.SetupSyncAPIComponent(base, deviceDB, accountDB, rsAPI, federation, cfg)
|
||||||
|
|
||||||
httpHandler := internal.WrapHandlerInCORS(base.PublicAPIMux)
|
|
||||||
|
|
||||||
// Set up the API endpoints we handle. /metrics is for prometheus, and is
|
// Set up the API endpoints we handle. /metrics is for prometheus, and is
|
||||||
// not wrapped by CORS, while everything else is
|
// not wrapped by CORS, while everything else is
|
||||||
if cfg.Metrics.Enabled {
|
if cfg.Metrics.Enabled {
|
||||||
http.Handle("/metrics", internal.WrapHandlerInBasicAuth(promhttp.Handler(), cfg.Metrics.BasicAuth))
|
http.Handle("/metrics", internal.WrapHandlerInBasicAuth(promhttp.Handler(), cfg.Metrics.BasicAuth))
|
||||||
}
|
}
|
||||||
http.Handle("/_matrix", httpHandler)
|
http.Handle("/_matrix", internal.WrapHandlerInCORS(base.PublicAPIMux))
|
||||||
if base.EnableHTTPAPIs {
|
if base.EnableHTTPAPIs {
|
||||||
http.Handle("/api/", base.InternalAPIMux)
|
http.Handle("/api/", base.InternalAPIMux)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -227,8 +227,7 @@ func main() {
|
||||||
publicroomsapi.SetupPublicRoomsAPIComponent(base, deviceDB, publicRoomsDB, rsAPI, federation, p2pPublicRoomProvider)
|
publicroomsapi.SetupPublicRoomsAPIComponent(base, deviceDB, publicRoomsDB, rsAPI, federation, p2pPublicRoomProvider)
|
||||||
syncapi.SetupSyncAPIComponent(base, deviceDB, accountDB, rsAPI, federation, cfg)
|
syncapi.SetupSyncAPIComponent(base, deviceDB, accountDB, rsAPI, federation, cfg)
|
||||||
|
|
||||||
httpHandler := internal.WrapHandlerInCORS(base.PublicAPIMux)
|
http.Handle("/_matrix", internal.WrapHandlerInCORS(base.PublicAPIMux))
|
||||||
http.Handle("/_matrix", httpHandler)
|
|
||||||
if base.EnableHTTPAPIs {
|
if base.EnableHTTPAPIs {
|
||||||
http.Handle("/api/", base.InternalAPIMux)
|
http.Handle("/api/", base.InternalAPIMux)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,7 @@ func (b *BaseDendrite) SetupAndServeHTTP(bindaddr string, listenaddr string) {
|
||||||
|
|
||||||
internal.SetupHTTPAPI(
|
internal.SetupHTTPAPI(
|
||||||
http.DefaultServeMux,
|
http.DefaultServeMux,
|
||||||
internal.WrapHandlerInCORS(b.PublicAPIMux),
|
b.PublicAPIMux,
|
||||||
b.InternalAPIMux,
|
b.InternalAPIMux,
|
||||||
b.Cfg,
|
b.Cfg,
|
||||||
b.EnableHTTPAPIs,
|
b.EnableHTTPAPIs,
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,7 @@ func SetupHTTPAPI(servMux *http.ServeMux, publicApiMux http.Handler, internalApi
|
||||||
if enableHTTPAPIs {
|
if enableHTTPAPIs {
|
||||||
servMux.Handle("/api/", internalApiMux)
|
servMux.Handle("/api/", internalApiMux)
|
||||||
}
|
}
|
||||||
servMux.Handle("/_matrix", publicApiMux)
|
servMux.Handle("/_matrix", WrapHandlerInCORS(publicApiMux))
|
||||||
}
|
}
|
||||||
|
|
||||||
// WrapHandlerInBasicAuth adds basic auth to a handler. Only used for /metrics
|
// WrapHandlerInBasicAuth adds basic auth to a handler. Only used for /metrics
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue