proxy

package
v0.0.0-...-1e0776f Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package proxy provides HTTP proxying for plugin routes. It handles routing HTTP requests to plugin gRPC handlers, including capability-based routing, rate limiting, and streaming support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPProxy

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

HTTPProxy handles proxying HTTP requests to plugin gRPC handlers.

func NewHTTPProxy

func NewHTTPProxy(
	pluginLookup PluginLookup,
	routeRegistry *registry.RouteRegistry,
	capabilityRegistry *registry.CapabilityRegistry,
	rateLimiter *registry.RouteRateLimiter,
	logger *slog.Logger,
) *HTTPProxy

NewHTTPProxy creates a new HTTP proxy for plugin routes.

func (*HTTPProxy) GetCapabilityRegistry

func (p *HTTPProxy) GetCapabilityRegistry() *registry.CapabilityRegistry

GetCapabilityRegistry returns the capability registry.

func (*HTTPProxy) GetRouteRegistry

func (p *HTTPProxy) GetRouteRegistry() *registry.RouteRegistry

GetRouteRegistry returns the route registry.

func (*HTTPProxy) HandleCapabilityRoute

func (p *HTTPProxy) HandleCapabilityRoute(capability string) gin.HandlerFunc

HandleCapabilityRoute returns a handler for capability-aliased routes. For example, /api/search is aliased to the "search" capability.

func (*HTTPProxy) HandlePluginRoute

func (p *HTTPProxy) HandlePluginRoute(c *gin.Context)

HandlePluginRoute handles requests to /api/plugins/:plugin_id/*path. It routes the request to the appropriate plugin's HandleHTTP or HandleHTTPStream.

func (*HTTPProxy) InitFromPlugins

func (p *HTTPProxy) InitFromPlugins(ctx context.Context, plugins []*types.Instance) error

InitFromPlugins initializes route and capability registries from loaded plugins. Call this after all plugins are loaded.

func (*HTTPProxy) RegisterCapabilityRoutes

func (p *HTTPProxy) RegisterCapabilityRoutes(router *gin.RouterGroup)

RegisterCapabilityRoutes registers all capability alias routes on the router. Call this after loading plugins to set up stable URLs like /api/search. Routes are registered dynamically based on plugins that declare alias_path in their routes. The router should already have authentication middleware applied.

func (*HTTPProxy) Stop

func (p *HTTPProxy) Stop()

Stop cleans up resources.

func (*HTTPProxy) UnregisterPlugin

func (p *HTTPProxy) UnregisterPlugin(pluginID string)

UnregisterPlugin removes routes and capabilities for a plugin.

type PluginLookup

type PluginLookup interface {
	GetPlugin(id string) (*types.Instance, bool)
	RestartPlugin(ctx context.Context, pluginID string) error
}

PluginLookup provides access to plugin instances. This interface allows the proxy to work without depending on the manager package directly.

Jump to

Keyboard shortcuts

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