Documentation
¶
Index ¶
- func DefaultMiddlewareConfig() *config.Config
- func Run(ctx context.Context, cfg Config) error
- type Config
- type DummyUpstream
- type MiddlewareManager
- type ProxyConfig
- type ProxyManager
- type ProxyServerConfig
- type ResolvedConfig
- type ServerConfig
- type ServerConfigWrapper
- type SimpleMiddlewareManager
- type SimpleProxyManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultMiddlewareConfig ¶ added in v0.9.0
DefaultMiddlewareConfig returns a default middleware configuration for running without a config file
Types ¶
type Config ¶
type Config struct {
ConfigPath string
Host string // From command-line flag
Port int // From command-line flag
HostSet bool // Whether host was explicitly set via flag
PortSet bool // Whether port was explicitly set via flag
Logger logging.Logger
Version string
}
Config represents the configuration for running the server
type DummyUpstream ¶ added in v0.9.0
type DummyUpstream struct {
// contains filtered or unexported fields
}
DummyUpstream is a simple HTTP server for testing purposes when no upstream is configured
func NewDummyUpstream ¶ added in v0.9.0
func NewDummyUpstream(logger logging.Logger) *DummyUpstream
NewDummyUpstream creates and starts a new dummy upstream server on an automatically selected available port. Returns the server instance or nil if startup fails (with a warning logged).
func (*DummyUpstream) Stop ¶ added in v0.9.0
func (d *DummyUpstream) Stop()
Stop stops the dummy upstream server with a timeout This method is non-blocking and will force close after timeout
func (*DummyUpstream) URL ¶ added in v0.9.0
func (d *DummyUpstream) URL() string
URL returns the URL of the dummy upstream server
type MiddlewareManager ¶
type MiddlewareManager interface {
// Handler returns the HTTP handler that includes the middleware and proxies to the next handler
Handler() http.Handler
// SetDraining marks the middleware as draining (shutting down gracefully)
SetDraining()
}
MiddlewareManager is an interface for managing middleware lifecycle
type ProxyConfig ¶
type ProxyConfig struct {
Proxy ProxyServerConfig `yaml:"proxy" json:"proxy"`
}
ProxyConfig represents the proxy configuration section in the config file
type ProxyManager ¶
type ProxyManager interface {
// Handler returns the HTTP handler that proxies requests to the upstream
Handler() http.Handler
}
ProxyManager is an interface for managing proxy lifecycle
type ProxyServerConfig ¶
type ProxyServerConfig struct {
Upstream proxy.UpstreamConfig `yaml:"upstream" json:"upstream"`
}
ProxyServerConfig represents proxy server settings
type ResolvedConfig ¶
ResolvedConfig represents the final resolved configuration
type ServerConfig ¶
type ServerConfig struct {
Host string `yaml:"host" json:"host"`
Port int `yaml:"port" json:"port"`
}
ServerConfig represents server settings from config file
type ServerConfigWrapper ¶
type ServerConfigWrapper struct {
Server ServerConfig `yaml:"server" json:"server"`
}
ServerConfigWrapper represents the server configuration section in the config file
type SimpleMiddlewareManager ¶
type SimpleMiddlewareManager struct {
// contains filtered or unexported fields
}
SimpleMiddlewareManager is a simple implementation of MiddlewareManager with hot reload support
func NewMiddlewareManager ¶
func NewMiddlewareManager(configPath string, host string, port int, next http.Handler, logger logging.Logger) (*SimpleMiddlewareManager, error)
NewMiddlewareManager creates a new SimpleMiddlewareManager from config file
func NewMiddlewareManagerWithDefault ¶ added in v0.9.0
func NewMiddlewareManagerWithDefault(configPath string, defaultConfig *config.Config, host string, port int, next http.Handler, logger logging.Logger) (*SimpleMiddlewareManager, error)
NewMiddlewareManagerWithDefault creates a new SimpleMiddlewareManager from config file with fallback to default config when the file is not found
func (*SimpleMiddlewareManager) Handler ¶
func (m *SimpleMiddlewareManager) Handler() http.Handler
Handler returns the HTTP handler The handler always uses the latest middleware stored atomically
func (*SimpleMiddlewareManager) OnFileChange ¶
func (m *SimpleMiddlewareManager) OnFileChange(event filewatcher.ChangeEvent)
OnFileChange implements filewatcher.ChangeListener interface This method is called when the configuration file changes
func (*SimpleMiddlewareManager) SetDraining ¶ added in v0.6.0
func (m *SimpleMiddlewareManager) SetDraining()
SetDraining marks the middleware as draining (shutting down gracefully)
type SimpleProxyManager ¶
type SimpleProxyManager struct {
// contains filtered or unexported fields
}
SimpleProxyManager is a simple implementation of ProxyManager with hot reload support
func NewProxyManager ¶
func NewProxyManager(configPath string, logger logging.Logger) (*SimpleProxyManager, error)
NewProxyManager creates a new SimpleProxyManager from config file
func NewProxyManagerWithDefault ¶ added in v0.9.0
func NewProxyManagerWithDefault(configPath string, defaultConfig *proxy.UpstreamConfig, logger logging.Logger) (*SimpleProxyManager, error)
NewProxyManagerWithDefault creates a new SimpleProxyManager from config file with fallback to default config when the file is not found
func (*SimpleProxyManager) Handler ¶
func (m *SimpleProxyManager) Handler() http.Handler
Handler returns the HTTP handler The handler always uses the latest proxy handler stored atomically
func (*SimpleProxyManager) OnFileChange ¶
func (m *SimpleProxyManager) OnFileChange(event filewatcher.ChangeEvent)
OnFileChange implements filewatcher.ChangeListener interface This method is called when the configuration file changes