diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2020-08-13 12:16:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-13 12:16:37 +0100 |
commit | 9677a95afc529d1766d487db46965266c6fbaa6a (patch) | |
tree | d98ccf518a3f8386054f93be4138988def9848be /cmd/dendritejs/main.go | |
parent | 820c56c165ec8f0409d23cd151a7ff89fbe09ffa (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 'cmd/dendritejs/main.go')
-rw-r--r-- | cmd/dendritejs/main.go | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/cmd/dendritejs/main.go b/cmd/dendritejs/main.go index f350a938..ada48cd8 100644 --- a/cmd/dendritejs/main.go +++ b/cmd/dendritejs/main.go @@ -21,6 +21,7 @@ import ( "fmt" "syscall/js" + "github.com/gorilla/mux" "github.com/matrix-org/dendrite/appservice" "github.com/matrix-org/dendrite/currentstateserver" "github.com/matrix-org/dendrite/eduserver" @@ -234,22 +235,28 @@ func main() { //ServerKeyAPI: serverKeyAPI, ExtPublicRoomsProvider: p2pPublicRoomProvider, } - monolith.AddAllPublicRoutes(base.PublicAPIMux) - - httputil.SetupHTTPAPI( - base.BaseMux, - base.PublicAPIMux, - base.InternalAPIMux, - &cfg.Global, - base.UseHTTPAPIs, + monolith.AddAllPublicRoutes( + base.PublicClientAPIMux, + base.PublicFederationAPIMux, + base.PublicKeyAPIMux, + base.PublicMediaAPIMux, ) + httpRouter := mux.NewRouter() + httpRouter.PathPrefix(httputil.InternalPathPrefix).Handler(base.InternalAPIMux) + httpRouter.PathPrefix(httputil.PublicClientPathPrefix).Handler(base.PublicClientAPIMux) + httpRouter.PathPrefix(httputil.PublicMediaPathPrefix).Handler(base.PublicMediaAPIMux) + + libp2pRouter := mux.NewRouter() + libp2pRouter.PathPrefix(httputil.PublicFederationPathPrefix).Handler(base.PublicFederationAPIMux) + libp2pRouter.PathPrefix(httputil.PublicMediaPathPrefix).Handler(base.PublicMediaAPIMux) + // Expose the matrix APIs via libp2p-js - for federation traffic if node != nil { go func() { logrus.Info("Listening on libp2p-js host ID ", node.Id) s := JSServer{ - Mux: base.BaseMux, + Mux: libp2pRouter, } s.ListenAndServe("p2p") }() @@ -259,7 +266,7 @@ func main() { go func() { logrus.Info("Listening for service-worker fetch traffic") s := JSServer{ - Mux: base.BaseMux, + Mux: httpRouter, } s.ListenAndServe("fetch") }() |