Documentation
¶
Overview ¶
Package middleware provides Hockeypuck-compatible middleware patterns This ensures plugins work seamlessly with interpose middleware chains
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MetricsMiddleware ¶
MetricsMiddleware provides request metrics
Types ¶
type InterposePriority ¶
type InterposePriority int
InterposePriority defines middleware execution order
const ( // High priority - runs first (security, auth) PriorityHigh InterposePriority = 100 // Medium priority - runs in middle (rate limiting, validation) PriorityMedium InterposePriority = 50 // Low priority - runs last (logging, metrics) PriorityLow InterposePriority = 10 )
type Middleware ¶
type Middleware struct {
Name string
Priority InterposePriority
Handler func(http.Handler) http.Handler
Path string // Path pattern this middleware applies to
}
Middleware represents a plugin middleware with priority
type MiddlewareChain ¶
type MiddlewareChain struct {
// contains filtered or unexported fields
}
MiddlewareChain manages ordered middleware execution compatible with interpose
func NewMiddlewareChain ¶
func NewMiddlewareChain(logger *log.Logger) *MiddlewareChain
NewMiddlewareChain creates a new middleware chain
func (*MiddlewareChain) Add ¶
func (mc *MiddlewareChain) Add(middleware Middleware)
Add adds middleware to the chain
func (*MiddlewareChain) Build ¶
func (mc *MiddlewareChain) Build() func(http.Handler) http.Handler
Build creates the final middleware handler compatible with interpose
func (*MiddlewareChain) GetMiddlewares ¶
func (mc *MiddlewareChain) GetMiddlewares() []Middleware
GetMiddlewares returns all registered middlewares for inspection
type PathMatcher ¶
type PathMatcher struct {
// contains filtered or unexported fields
}
PathMatcher provides path-based middleware application
func NewPathMatcher ¶
func NewPathMatcher(logger *log.Logger) *PathMatcher
NewPathMatcher creates a new path matcher
func (*PathMatcher) Middleware ¶
func (pm *PathMatcher) Middleware() func(http.Handler) http.Handler
Middleware returns a middleware that applies path-specific handlers
type PluginMiddlewareWrapper ¶
type PluginMiddlewareWrapper struct {
// contains filtered or unexported fields
}
PluginMiddlewareWrapper wraps plugin middleware for interpose compatibility
func NewPluginMiddlewareWrapper ¶
func NewPluginMiddlewareWrapper(pluginName string, logger *log.Logger) *PluginMiddlewareWrapper
NewPluginMiddlewareWrapper creates a wrapper for plugin middleware
func (*PluginMiddlewareWrapper) WrapMiddleware ¶
func (pmw *PluginMiddlewareWrapper) WrapMiddleware( middleware func(http.Handler) http.Handler, priority InterposePriority, ) func(http.Handler) http.Handler
WrapMiddleware wraps plugin middleware with logging and error handling