diff --git a/gateway.go b/gateway.go index 97fc2590..a14d57e9 100644 --- a/gateway.go +++ b/gateway.go @@ -53,6 +53,10 @@ func (g *Gateway) Router(cfg *Config) http.Handler { gatewayHandler.Use(extension.Introspection{}) } + for _, plugin := range g.plugins { + plugin.SetupGatewayHandler(gatewayHandler) + } + mux.Handle("/query", applyMiddleware(otelhttp.NewHandler(gatewayHandler, "/query"), debugMiddleware)) for _, plugin := range g.plugins { diff --git a/plugin.go b/plugin.go index f2ec6dd5..d040ccdd 100644 --- a/plugin.go +++ b/plugin.go @@ -6,6 +6,7 @@ import ( "net/http" "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/handler" log "github.com/sirupsen/logrus" ) @@ -20,6 +21,7 @@ type Plugin interface { // Init is called once on initialization Init(schema *ExecutableSchema) SetupPublicMux(mux *http.ServeMux) + SetupGatewayHandler(handler *handler.Server) SetupPrivateMux(mux *http.ServeMux) // Should return true and the query path if the plugin is a service that // should be federated by Bramble @@ -44,6 +46,8 @@ func (p *BasePlugin) Configure(*Config, json.RawMessage) error { // Init ... func (p *BasePlugin) Init(s *ExecutableSchema) {} +func (p *BasePlugin) SetupGatewayHandler(handler *handler.Server) {} + // SetupPublicMux ... func (p *BasePlugin) SetupPublicMux(mux *http.ServeMux) {}