Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Name string `yaml:"name" json:"name"`
Endpoint string `yaml:"endpoint" json:"endpoint"`
Timeout string `yaml:"timeout,omitempty" json:"timeout,omitempty"`
}
Config mirrors plugins: section in snapshot.
type Plugin ¶
type Plugin struct {
Name string
// BeforeRequest can mutate the outgoing upstream request (e.g., add headers, compress).
BeforeRequest func(ctx context.Context, req *http.Request) error
// AfterResponse can post-process the upstream response headers (e.g., add quota headers).
AfterResponse func(ctx context.Context, h http.Header) error
// Compress is called for tool_result compression (like RTK) — return new body, true if modified.
Compress func(body []byte) ([]byte, bool)
// Endpoint is an HTTP sidecar URL for out-of-process plugins (like caddy).
// If set, BeforeRequest/AfterResponse are not used; instead the gateway POSTs
// JSON to endpoint + "/before" or "/after" with 10ms timeout.
Endpoint string
Timeout time.Duration
}
Plugin is a gateway extension. It can be in-process (Go func) or out-of-process HTTP sidecar (endpoint). This mirrors dsh's seam idea but pragmatic for Go gateway:
Service Definition = Hook func signature Service Provider = Plugin struct (in-process or HTTP sidecar) Consumer = proxy/router (calls Registry.Hooks)
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds all registered plugins. Like dsh's Cordis context, but simple.
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) AfterResponse ¶
AfterResponse runs all plugins' AfterResponse hooks.
func (*Registry) BeforeRequest ¶
BeforeRequest runs all plugins' BeforeRequest hooks. If any returns error, the request is aborted.