Skip to content

Commit

Permalink
Merge pull request #267 from suhodolskiy/main
Browse files Browse the repository at this point in the history
Add ability to expand gateway handler for plugins
  • Loading branch information
pkqk authored May 1, 2024
2 parents b60dd36 + 4bbd234 commit f324901
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/http"

"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/handler"
log "github.com/sirupsen/logrus"
)

Expand All @@ -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
Expand All @@ -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) {}

Expand Down

0 comments on commit f324901

Please sign in to comment.