mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-29 12:42:46 +00:00
Separate muxes for public and internal APIs (#1056)
* Separate muxes for public and internal APIs * Update client-api-proxy and federation-api-proxy so they don't add /api to the path * Tidy up * Consistent HTTP setup * Set up prefixes properly
This commit is contained in:
parent
f223da2f35
commit
fe82e1f725
29 changed files with 131 additions and 119 deletions
|
@ -15,8 +15,6 @@
|
|||
package federationsender
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/matrix-org/dendrite/federationsender/api"
|
||||
"github.com/matrix-org/dendrite/federationsender/consumers"
|
||||
"github.com/matrix-org/dendrite/federationsender/internal"
|
||||
|
@ -72,9 +70,7 @@ func SetupFederationSenderComponent(
|
|||
statistics,
|
||||
)
|
||||
|
||||
if base.EnableHTTPAPIs {
|
||||
queryAPI.SetupHTTP(http.DefaultServeMux)
|
||||
}
|
||||
queryAPI.SetupHTTP(base.InternalAPIMux)
|
||||
|
||||
return queryAPI
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/matrix-org/dendrite/federationsender/api"
|
||||
"github.com/matrix-org/dendrite/federationsender/producers"
|
||||
"github.com/matrix-org/dendrite/federationsender/storage"
|
||||
|
@ -43,8 +44,8 @@ func NewFederationSenderInternalAPI(
|
|||
}
|
||||
|
||||
// SetupHTTP adds the FederationSenderInternalAPI handlers to the http.ServeMux.
|
||||
func (f *FederationSenderInternalAPI) SetupHTTP(servMux *http.ServeMux) {
|
||||
servMux.Handle(
|
||||
func (f *FederationSenderInternalAPI) SetupHTTP(internalAPIMux *mux.Router) {
|
||||
internalAPIMux.Handle(
|
||||
api.FederationSenderQueryJoinedHostsInRoomPath,
|
||||
internal.MakeInternalAPI("QueryJoinedHostsInRoom", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryJoinedHostsInRoomRequest
|
||||
|
@ -58,7 +59,7 @@ func (f *FederationSenderInternalAPI) SetupHTTP(servMux *http.ServeMux) {
|
|||
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
|
||||
}),
|
||||
)
|
||||
servMux.Handle(
|
||||
internalAPIMux.Handle(
|
||||
api.FederationSenderQueryJoinedHostServerNamesInRoomPath,
|
||||
internal.MakeInternalAPI("QueryJoinedHostServerNamesInRoom", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryJoinedHostServerNamesInRoomRequest
|
||||
|
@ -72,7 +73,7 @@ func (f *FederationSenderInternalAPI) SetupHTTP(servMux *http.ServeMux) {
|
|||
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
|
||||
}),
|
||||
)
|
||||
servMux.Handle(api.FederationSenderPerformJoinRequestPath,
|
||||
internalAPIMux.Handle(api.FederationSenderPerformJoinRequestPath,
|
||||
internal.MakeInternalAPI("PerformJoinRequest", func(req *http.Request) util.JSONResponse {
|
||||
var request api.PerformJoinRequest
|
||||
var response api.PerformJoinResponse
|
||||
|
@ -85,7 +86,7 @@ func (f *FederationSenderInternalAPI) SetupHTTP(servMux *http.ServeMux) {
|
|||
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
|
||||
}),
|
||||
)
|
||||
servMux.Handle(api.FederationSenderPerformLeaveRequestPath,
|
||||
internalAPIMux.Handle(api.FederationSenderPerformLeaveRequestPath,
|
||||
internal.MakeInternalAPI("PerformLeaveRequest", func(req *http.Request) util.JSONResponse {
|
||||
var request api.PerformLeaveRequest
|
||||
var response api.PerformLeaveResponse
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue