plugin

package
v1.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package plugin provides the gateway plugin system for extending the proxy pipeline with custom request/response processing logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GraphQLConfig

type GraphQLConfig struct {
	// MaxDepth limits query nesting depth (0 = unlimited).
	MaxDepth int `json:"maxDepth"`

	// MaxComplexity limits estimated query complexity (0 = unlimited).
	MaxComplexity int `json:"maxComplexity"`

	// BlockIntrospection rejects __schema and __type queries.
	BlockIntrospection bool `json:"blockIntrospection"`

	// AllowedOperations limits which operation types are permitted.
	// Empty = all allowed. Values: "query", "mutation", "subscription".
	AllowedOperations []string `json:"allowedOperations,omitempty"`
}

GraphQLConfig configures GraphQL-specific gateway behaviour.

type GraphQLGuard

type GraphQLGuard struct {
	// contains filtered or unexported fields
}

GraphQLGuard enforces depth limits, complexity limits, and introspection blocking on GraphQL routes.

func NewGraphQLGuard

func NewGraphQLGuard(cfg GraphQLConfig) *GraphQLGuard

NewGraphQLGuard creates a guard with the given configuration.

func (*GraphQLGuard) Check

func (g *GraphQLGuard) Check(r *http.Request) error

Check validates a GraphQL HTTP request against the configured rules. It returns an error string suitable for a JSON error response, or "" if OK.

type GraphQLPlugin

type GraphQLPlugin struct {
	bastion.BasePlugin
	// contains filtered or unexported fields
}

GraphQLPlugin is a GatewayPlugin that enforces GraphQL rules on routes with Protocol == ProtocolGraphQL.

func NewGraphQLPlugin

func NewGraphQLPlugin(cfg GraphQLConfig) *GraphQLPlugin

NewGraphQLPlugin creates a plugin with a global GraphQL config. Per-route configs can be set via SetRouteConfig.

func (*GraphQLPlugin) OnRequest

func (p *GraphQLPlugin) OnRequest(r *http.Request, route *bastion.Route) error

OnRequest validates GraphQL requests on GraphQL-protocol routes.

func (*GraphQLPlugin) SetRouteConfig

func (p *GraphQLPlugin) SetRouteConfig(routeID string, cfg GraphQLConfig)

SetRouteConfig sets a per-route GraphQL configuration.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager registers and invokes gateway plugins. It integrates with the HookEngine to participate in the proxy pipeline.

func NewManager

func NewManager() *Manager

NewManager creates a new plugin manager.

func (*Manager) PluginNames

func (pm *Manager) PluginNames() []string

PluginNames returns the names of all registered plugins.

func (*Manager) Plugins

func (pm *Manager) Plugins() []bastion.GatewayPlugin

Plugins returns a snapshot of all registered plugins.

func (*Manager) Register

func (pm *Manager) Register(plugin bastion.GatewayPlugin, hooks *bastion.HookEngine)

Register adds a plugin. It also wires the plugin into the provided HookEngine so existing hook-based callers invoke plugin methods.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL