Documentation
¶
Overview ¶
Package reverseproxy provides circuit breaker implementation for backend proxies.
Package reverseproxy provides a flexible reverse proxy module with support for multiple backends, composite responses, and tenant awareness.
Package reverseproxy provides configuration structures for the reverse proxy module.
Package reverseproxy provides error definitions for the reverse proxy module.
Package reverseproxy provides metrics collection for the reverse proxy module.
Package reverseproxy provides a flexible reverse proxy module with support for multiple backends, composite responses, and tenant awareness.
Package reverseproxy provides retry functionality for the reverse proxy module.
Package reverseproxy provides a flexible reverse proxy module with support for multiple backends, composite responses, and tenant awareness.
Index ¶
- Variables
- func ProvideConfig() interface{}
- func RetryWithPolicy(ctx context.Context, policy RetryPolicy, fn RetryFunc, ...) (interface{}, int, error)
- func TenantIDFromRequest(tenantHeader string, r *http.Request) (string, bool)
- type Backend
- type BackendConfig
- type BackendEndpointRequest
- type CachedResponse
- type CircuitBreaker
- func (cb *CircuitBreaker) Execute(req *http.Request, fn func(*http.Request) (*http.Response, error)) (*http.Response, error)
- func (cb *CircuitBreaker) GetState() CircuitState
- func (cb *CircuitBreaker) IsOpen() bool
- func (cb *CircuitBreaker) RecordFailure()
- func (cb *CircuitBreaker) RecordSuccess()
- func (cb *CircuitBreaker) Reset()
- func (cb *CircuitBreaker) WithFailureThreshold(threshold int) *CircuitBreaker
- func (cb *CircuitBreaker) WithMetricsCollector(collector *MetricsCollector) *CircuitBreaker
- func (cb *CircuitBreaker) WithRequestTimeout(timeout time.Duration) *CircuitBreaker
- func (cb *CircuitBreaker) WithResetTimeout(timeout time.Duration) *CircuitBreaker
- type CircuitBreakerConfig
- type CircuitState
- type CompositeHandler
- type CompositeResponse
- type CompositeRoute
- type Config
- type EndpointMapping
- type MetricsCollector
- func (m *MetricsCollector) GetMetrics() map[string]interface{}
- func (m *MetricsCollector) MetricsHandler() http.HandlerFunc
- func (m *MetricsCollector) RecordRequest(backend string, start time.Time, statusCode int, err error, ...)
- func (m *MetricsCollector) SetCircuitBreakerStateString(backend string, state string)
- func (m *MetricsCollector) SetCircuitBreakerStatus(backend string, isOpen bool)
- type PathMatcher
- type RetryConfig
- type RetryFunc
- type RetryPolicy
- func (p RetryPolicy) CalculateBackoff(attempt int) time.Duration
- func (p RetryPolicy) ShouldRetry(statusCode int) bool
- func (p RetryPolicy) WithBaseDelay(baseDelay time.Duration) RetryPolicy
- func (p RetryPolicy) WithJitter(jitter float64) RetryPolicy
- func (p RetryPolicy) WithMaxDelay(maxDelay time.Duration) RetryPolicy
- func (p RetryPolicy) WithMaxRetries(maxRetries int) RetryPolicy
- func (p RetryPolicy) WithRetryableStatusCodes(codes ...int) RetryPolicy
- func (p RetryPolicy) WithTimeout(timeout time.Duration) RetryPolicy
- type ReverseProxyConfig
- type ReverseProxyModule
- func (m *ReverseProxyModule) AddBackendRoute(backendID, routePattern string) error
- func (m *ReverseProxyModule) AddCompositeRoute(pattern string, backends []string, strategy string)
- func (m *ReverseProxyModule) Constructor() modular.ModuleConstructor
- func (m *ReverseProxyModule) GetConfig() *ReverseProxyConfig
- func (m *ReverseProxyModule) Init(app modular.Application) error
- func (m *ReverseProxyModule) Name() string
- func (m *ReverseProxyModule) OnTenantRegistered(tenantID modular.TenantID)
- func (m *ReverseProxyModule) OnTenantRemoved(tenantID modular.TenantID)
- func (m *ReverseProxyModule) ProvidesServices() []modular.ServiceProvider
- func (m *ReverseProxyModule) RegisterConfig(app modular.Application) error
- func (m *ReverseProxyModule) RegisterCustomEndpoint(pattern string, mapping EndpointMapping)
- func (m *ReverseProxyModule) RequiresServices() []modular.ServiceDependency
- func (m *ReverseProxyModule) SetHttpClient(client *http.Client)
- func (m *ReverseProxyModule) Start(context.Context) error
- func (m *ReverseProxyModule) Stop(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCircuitOpen defined in circuit_breaker.go ErrMaxRetriesReached = errors.New("maximum number of retries reached") ErrRequestTimeout = errors.New("request timed out") ErrNoAvailableBackend = errors.New("no available backend") )
Error definitions for the reverse proxy module.
var ( // ErrCircuitOpen is returned when the circuit is open and requests are not allowed. ErrCircuitOpen = errors.New("circuit breaker is open") )
Functions ¶
func ProvideConfig ¶
func ProvideConfig() interface{}
ProvideConfig creates a new default configuration for the reverseproxy module. This is used by the modular framework to register the configuration.
func RetryWithPolicy ¶ added in v1.0.6
func RetryWithPolicy(ctx context.Context, policy RetryPolicy, fn RetryFunc, metrics *MetricsCollector, backendID string) (interface{}, int, error)
RetryWithPolicy executes the given function with retries according to the policy.
Types ¶
type BackendConfig ¶ added in v1.0.6
type BackendConfig struct { URL string `json:"url" yaml:"url"` Timeout time.Duration `json:"timeout" yaml:"timeout"` MaxIdleConns int `json:"max_idle_conns" yaml:"max_idle_conns"` MaxIdleConnsPerHost int `json:"max_idle_conns_per_host" yaml:"max_idle_conns_per_host"` MaxConnsPerHost int `json:"max_conns_per_host" yaml:"max_conns_per_host"` IdleConnTimeout time.Duration `json:"idle_conn_timeout" yaml:"idle_conn_timeout"` TLSSkipVerify bool `json:"tls_skip_verify" yaml:"tls_skip_verify"` CircuitBreaker *CircuitBreakerConfig `json:"circuit_breaker" yaml:"circuit_breaker"` Retry *RetryConfig `json:"retry" yaml:"retry"` }
BackendConfig provides configuration for a backend server.
type BackendEndpointRequest ¶
type BackendEndpointRequest struct { Backend string Method string Path string Headers map[string]string QueryParams map[string]string }
BackendEndpointRequest defines a request to be sent to a backend
type CachedResponse ¶
type CachedResponse struct { StatusCode int Headers http.Header Body []byte LastAccessed time.Time ExpirationTime time.Time }
CachedResponse represents a cached HTTP response
type CircuitBreaker ¶
type CircuitBreaker struct {
// contains filtered or unexported fields
}
CircuitBreaker implements the circuit breaker pattern for HTTP requests.
func NewCircuitBreaker ¶
func NewCircuitBreaker(backendName string, metricsCollector *MetricsCollector) *CircuitBreaker
NewCircuitBreaker creates a new CircuitBreaker with default settings.
func NewCircuitBreakerWithConfig ¶ added in v1.0.6
func NewCircuitBreakerWithConfig(backendName string, config CircuitBreakerConfig, metricsCollector *MetricsCollector) *CircuitBreaker
NewCircuitBreakerWithConfig creates a new CircuitBreaker with custom settings.
func (*CircuitBreaker) Execute ¶ added in v1.0.6
func (cb *CircuitBreaker) Execute(req *http.Request, fn func(*http.Request) (*http.Response, error)) (*http.Response, error)
Execute executes the provided function with circuit breaker protection.
func (*CircuitBreaker) GetState ¶
func (cb *CircuitBreaker) GetState() CircuitState
GetState returns the current state of the circuit breaker.
func (*CircuitBreaker) IsOpen ¶
func (cb *CircuitBreaker) IsOpen() bool
IsOpen returns true if the circuit is open (no requests should be made).
func (*CircuitBreaker) RecordFailure ¶
func (cb *CircuitBreaker) RecordFailure()
RecordFailure records a failed request and opens the circuit if threshold is reached.
func (*CircuitBreaker) RecordSuccess ¶
func (cb *CircuitBreaker) RecordSuccess()
RecordSuccess records a successful request and resets the failure count.
func (*CircuitBreaker) Reset ¶
func (cb *CircuitBreaker) Reset()
Reset resets the circuit breaker to closed state (capitalized for backward compatibility).
func (*CircuitBreaker) WithFailureThreshold ¶ added in v1.0.6
func (cb *CircuitBreaker) WithFailureThreshold(threshold int) *CircuitBreaker
WithFailureThreshold sets the number of failures required to open the circuit.
func (*CircuitBreaker) WithMetricsCollector ¶ added in v1.0.6
func (cb *CircuitBreaker) WithMetricsCollector(collector *MetricsCollector) *CircuitBreaker
WithMetricsCollector associates a metrics collector with this circuit breaker.
func (*CircuitBreaker) WithRequestTimeout ¶ added in v1.0.6
func (cb *CircuitBreaker) WithRequestTimeout(timeout time.Duration) *CircuitBreaker
WithRequestTimeout sets the timeout for each request protected by this circuit breaker.
func (*CircuitBreaker) WithResetTimeout ¶ added in v1.0.6
func (cb *CircuitBreaker) WithResetTimeout(timeout time.Duration) *CircuitBreaker
WithResetTimeout sets the duration to wait before allowing a test request.
type CircuitBreakerConfig ¶
type CircuitBreakerConfig struct { Enabled bool `json:"enabled" yaml:"enabled" env:"ENABLED"` FailureThreshold int `json:"failure_threshold" yaml:"failure_threshold" env:"FAILURE_THRESHOLD"` SuccessThreshold int `json:"success_threshold" yaml:"success_threshold" env:"SUCCESS_THRESHOLD"` OpenTimeout time.Duration `json:"open_timeout" yaml:"open_timeout" env:"OPEN_TIMEOUT"` HalfOpenAllowedRequests int `json:"half_open_allowed_requests" yaml:"half_open_allowed_requests" env:"HALF_OPEN_ALLOWED_REQUESTS"` WindowSize int `json:"window_size" yaml:"window_size" env:"WINDOW_SIZE"` SuccessRateThreshold float64 `json:"success_rate_threshold" yaml:"success_rate_threshold" env:"SUCCESS_RATE_THRESHOLD"` }
CircuitBreakerConfig provides configuration for the circuit breaker.
type CircuitState ¶
type CircuitState int
CircuitState represents the state of a circuit breaker.
const ( // StateClosed indicates the circuit is closed and allowing requests. StateClosed CircuitState = iota // StateOpen indicates the circuit is open and blocking requests. StateOpen // StateHalfOpen indicates the circuit is allowing a test request. StateHalfOpen )
func (CircuitState) String ¶ added in v1.0.6
func (s CircuitState) String() string
String returns a string representation of the circuit state.
type CompositeHandler ¶
type CompositeHandler struct {
// contains filtered or unexported fields
}
CompositeHandler is updated to handle multiple requests and process/merge them into a single response. It now includes circuit breaking and response caching.
func NewCompositeHandler ¶
func NewCompositeHandler(backends []*Backend, parallel bool, responseTimeout time.Duration) *CompositeHandler
NewCompositeHandler creates a new composite handler with the given backends.
func (*CompositeHandler) ConfigureCircuitBreakers ¶
func (h *CompositeHandler) ConfigureCircuitBreakers(globalConfig CircuitBreakerConfig, backendConfigs map[string]CircuitBreakerConfig)
ConfigureCircuitBreakers sets up circuit breakers for each backend using the provided configuration
func (*CompositeHandler) ServeHTTP ¶
func (h *CompositeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP handles the request by forwarding it to all backends and merging the responses.
func (*CompositeHandler) SetResponseCache ¶
func (h *CompositeHandler) SetResponseCache(cache *responseCache)
SetResponseCache sets a response cache for the handler.
type CompositeResponse ¶
CompositeResponse represents a transformed response from multiple backend requests
type CompositeRoute ¶
type CompositeRoute struct { Pattern string `json:"pattern" yaml:"pattern" env:"PATTERN"` Backends []string `json:"backends" yaml:"backends" env:"BACKENDS"` Strategy string `json:"strategy" yaml:"strategy" env:"STRATEGY"` }
CompositeRoute defines a route that combines responses from multiple backends.
type Config ¶ added in v1.0.6
type Config struct { Backends map[string]BackendConfig `json:"backends" yaml:"backends"` PrefixMapping map[string]string `json:"prefix_mapping" yaml:"prefix_mapping"` ExactMapping map[string]string `json:"exact_mapping" yaml:"exact_mapping"` MetricsEnabled bool `json:"metrics_enabled" yaml:"metrics_enabled"` MetricsPath string `json:"metrics_path" yaml:"metrics_path"` CircuitBreaker CircuitBreakerConfig `json:"circuit_breaker" yaml:"circuit_breaker"` Retry RetryConfig `json:"retry" yaml:"retry"` }
Config provides configuration options for the ReverseProxyModule. This is the original Config struct which is being phased out in favor of ReverseProxyConfig.
type EndpointMapping ¶
type EndpointMapping struct { // Endpoints lists the backend requests to make Endpoints []BackendEndpointRequest // ResponseTransformer is a function that transforms multiple backend responses // into a single composite response ResponseTransformer func(ctx context.Context, req *http.Request, responses map[string]*http.Response) (*CompositeResponse, error) }
EndpointMapping defines how requests should be routed to different backends and how their responses should be combined
type MetricsCollector ¶ added in v1.0.6
type MetricsCollector struct {
// contains filtered or unexported fields
}
MetricsCollector collects and provides metrics for the reverse proxy.
func NewMetricsCollector ¶ added in v1.0.6
func NewMetricsCollector() *MetricsCollector
NewMetricsCollector creates a new MetricsCollector.
func (*MetricsCollector) GetMetrics ¶ added in v1.0.6
func (m *MetricsCollector) GetMetrics() map[string]interface{}
GetMetrics returns the collected metrics.
func (*MetricsCollector) MetricsHandler ¶ added in v1.0.6
func (m *MetricsCollector) MetricsHandler() http.HandlerFunc
MetricsHandler returns an HTTP handler for metrics endpoint.
func (*MetricsCollector) RecordRequest ¶ added in v1.0.6
func (m *MetricsCollector) RecordRequest(backend string, start time.Time, statusCode int, err error, metadata ...map[string]string)
RecordRequest records a request to a backend.
func (*MetricsCollector) SetCircuitBreakerStateString ¶ added in v1.0.6
func (m *MetricsCollector) SetCircuitBreakerStateString(backend string, state string)
SetCircuitBreakerStateString sets the status of a circuit breaker with an explicit state string.
func (*MetricsCollector) SetCircuitBreakerStatus ¶ added in v1.0.6
func (m *MetricsCollector) SetCircuitBreakerStatus(backend string, isOpen bool)
SetCircuitBreakerStatus sets the status of a circuit breaker.
type PathMatcher ¶
type PathMatcher struct {
// contains filtered or unexported fields
}
PathMatcher helps determine which backend should handle a request based on path patterns. It maintains a mapping of backend IDs to URL path patterns and provides methods to register patterns and find matching backends for incoming requests.
func NewPathMatcher ¶
func NewPathMatcher() *PathMatcher
NewPathMatcher creates a new PathMatcher instance with initialized storage. This is used to create a fresh path matcher for route registration.
func (*PathMatcher) AddRoutePattern ¶
func (pm *PathMatcher) AddRoutePattern(backendID, pattern string)
AddRoutePattern adds a path pattern that should be routed to the specified backend. Multiple patterns can be registered for the same backend.
Parameters:
- backendID: The identifier of the backend service to route to
- pattern: The URL path pattern to match (e.g., "/api/users")
func (*PathMatcher) MatchBackend ¶
func (pm *PathMatcher) MatchBackend(path string) string
MatchBackend determines which backend should handle the given path. It checks if the path starts with any of the registered patterns and returns the matching backend ID. If multiple patterns match, the first match wins.
Parameters:
- path: The request path to match against registered patterns
Returns:
- The matching backendID or empty string if no match is found
type RetryConfig ¶ added in v1.0.6
type RetryConfig struct { Enabled bool `json:"enabled" yaml:"enabled"` MaxRetries int `json:"max_retries" yaml:"max_retries"` BaseDelay time.Duration `json:"base_delay" yaml:"base_delay"` MaxDelay time.Duration `json:"max_delay" yaml:"max_delay"` Jitter float64 `json:"jitter" yaml:"jitter"` Timeout time.Duration `json:"timeout" yaml:"timeout"` RetryableStatusCodes []int `json:"retryable_status_codes" yaml:"retryable_status_codes"` }
RetryConfig provides configuration for the retry policy.
type RetryPolicy ¶ added in v1.0.6
type RetryPolicy struct { // MaxRetries is the maximum number of retries to attempt. MaxRetries int // BaseDelay is the base delay between retries. BaseDelay time.Duration // MaxDelay is the maximum delay between retries. MaxDelay time.Duration // Jitter is the amount of randomness to add to the delay. Jitter float64 // RetryableStatusCodes is a list of status codes that should trigger a retry. RetryableStatusCodes map[int]bool // Timeout is the timeout for each attempt. Timeout time.Duration }
RetryPolicy defines the retry behavior for failing requests.
func DefaultRetryPolicy ¶ added in v1.0.6
func DefaultRetryPolicy() RetryPolicy
DefaultRetryPolicy returns a default retry policy.
func (RetryPolicy) CalculateBackoff ¶ added in v1.0.6
func (p RetryPolicy) CalculateBackoff(attempt int) time.Duration
CalculateBackoff calculates the backoff duration for a retry attempt.
func (RetryPolicy) ShouldRetry ¶ added in v1.0.6
func (p RetryPolicy) ShouldRetry(statusCode int) bool
ShouldRetry returns true if the status code should trigger a retry.
func (RetryPolicy) WithBaseDelay ¶ added in v1.0.6
func (p RetryPolicy) WithBaseDelay(baseDelay time.Duration) RetryPolicy
WithBaseDelay sets the base delay.
func (RetryPolicy) WithJitter ¶ added in v1.0.6
func (p RetryPolicy) WithJitter(jitter float64) RetryPolicy
WithJitter sets the jitter.
func (RetryPolicy) WithMaxDelay ¶ added in v1.0.6
func (p RetryPolicy) WithMaxDelay(maxDelay time.Duration) RetryPolicy
WithMaxDelay sets the maximum delay.
func (RetryPolicy) WithMaxRetries ¶ added in v1.0.6
func (p RetryPolicy) WithMaxRetries(maxRetries int) RetryPolicy
WithMaxRetries sets the maximum number of retries.
func (RetryPolicy) WithRetryableStatusCodes ¶ added in v1.0.6
func (p RetryPolicy) WithRetryableStatusCodes(codes ...int) RetryPolicy
WithRetryableStatusCodes sets the status codes that should trigger a retry.
func (RetryPolicy) WithTimeout ¶ added in v1.0.6
func (p RetryPolicy) WithTimeout(timeout time.Duration) RetryPolicy
WithTimeout sets the timeout for each attempt.
type ReverseProxyConfig ¶
type ReverseProxyConfig struct { BackendServices map[string]string `json:"backend_services" yaml:"backend_services" env:"BACKEND_SERVICES"` Routes map[string]string `json:"routes" yaml:"routes" env:"ROUTES"` DefaultBackend string `json:"default_backend" yaml:"default_backend" env:"DEFAULT_BACKEND"` CircuitBreakerConfig CircuitBreakerConfig `json:"circuit_breaker" yaml:"circuit_breaker"` BackendCircuitBreakers map[string]CircuitBreakerConfig `json:"backend_circuit_breakers" yaml:"backend_circuit_breakers"` CompositeRoutes map[string]CompositeRoute `json:"composite_routes" yaml:"composite_routes"` TenantIDHeader string `json:"tenant_id_header" yaml:"tenant_id_header" env:"TENANT_ID_HEADER"` RequireTenantID bool `json:"require_tenant_id" yaml:"require_tenant_id" env:"REQUIRE_TENANT_ID"` CacheEnabled bool `json:"cache_enabled" yaml:"cache_enabled" env:"CACHE_ENABLED"` CacheTTL time.Duration `json:"cache_ttl" yaml:"cache_ttl" env:"CACHE_TTL"` RequestTimeout time.Duration `json:"request_timeout" yaml:"request_timeout" env:"REQUEST_TIMEOUT"` MetricsEnabled bool `json:"metrics_enabled" yaml:"metrics_enabled" env:"METRICS_ENABLED"` MetricsPath string `json:"metrics_path" yaml:"metrics_path" env:"METRICS_PATH"` MetricsEndpoint string `json:"metrics_endpoint" yaml:"metrics_endpoint" env:"METRICS_ENDPOINT"` }
ReverseProxyConfig provides configuration options for the ReverseProxyModule.
type ReverseProxyModule ¶
type ReverseProxyModule struct {
// contains filtered or unexported fields
}
ReverseProxyModule provides a modular reverse proxy implementation with support for multiple backends, composite routes that combine responses from different backends, and tenant-specific routing configurations.
The module implements the following interfaces:
- modular.Module: Basic module lifecycle
- modular.Configurable: Configuration management
- modular.ServiceAware: Service dependency management
- modular.TenantAwareModule: Tenant lifecycle management
- modular.Startable: Startup logic
- modular.Stoppable: Shutdown logic
Key features include:
- Multi-backend proxy routing with health checks
- Composite responses combining multiple backend calls
- Circuit breakers for fault tolerance
- Response caching for performance optimization
- Tenant-aware routing and configuration
- Request/response transformation pipelines
- Comprehensive metrics collection
- Path-based and header-based routing rules
func NewModule ¶
func NewModule() *ReverseProxyModule
NewModule creates a new ReverseProxyModule with default settings. This is the primary constructor for the reverseproxy module and should be used when registering the module with the application.
The module initializes with:
- Optimized HTTP client with connection pooling
- Circuit breakers for each backend
- Response caching infrastructure
- Metrics collection (if enabled)
- Thread-safe data structures for concurrent access
Example:
app.RegisterModule(reverseproxy.NewModule())
func (*ReverseProxyModule) AddBackendRoute ¶
func (m *ReverseProxyModule) AddBackendRoute(backendID, routePattern string) error
AddBackendRoute registers a new route for a specific backend. It allows dynamically adding routes to the reverse proxy after initialization.
func (*ReverseProxyModule) AddCompositeRoute ¶
func (m *ReverseProxyModule) AddCompositeRoute(pattern string, backends []string, strategy string)
AddCompositeRoute adds a composite route that combines responses from multiple backends. The strategy parameter determines how the responses are combined.
func (*ReverseProxyModule) Constructor ¶
func (m *ReverseProxyModule) Constructor() modular.ModuleConstructor
Constructor returns a ModuleConstructor function that initializes the module with the required services. It expects a service that implements the routerService interface to register routes with.
func (*ReverseProxyModule) GetConfig ¶
func (m *ReverseProxyModule) GetConfig() *ReverseProxyConfig
GetConfig returns the module's configuration.
func (*ReverseProxyModule) Init ¶
func (m *ReverseProxyModule) Init(app modular.Application) error
Init initializes the module with the provided application. It retrieves the module's configuration and sets up the internal data structures for each configured backend, including tenant-specific configurations.
func (*ReverseProxyModule) Name ¶
func (m *ReverseProxyModule) Name() string
Name returns the name of the module. This is used by the modular framework to identify the module.
func (*ReverseProxyModule) OnTenantRegistered ¶
func (m *ReverseProxyModule) OnTenantRegistered(tenantID modular.TenantID)
OnTenantRegistered is called when a new tenant is registered with the application. Instead of immediately querying for tenant configuration, we store the tenant ID and defer configuration loading until the next appropriate phase to avoid deadlocks.
func (*ReverseProxyModule) OnTenantRemoved ¶
func (m *ReverseProxyModule) OnTenantRemoved(tenantID modular.TenantID)
OnTenantRemoved is called when a tenant is removed from the application. It removes the tenant's configuration and any associated resources.
func (*ReverseProxyModule) ProvidesServices ¶
func (m *ReverseProxyModule) ProvidesServices() []modular.ServiceProvider
ProvidesServices returns the services provided by this module. Currently, this module does not provide any services.
func (*ReverseProxyModule) RegisterConfig ¶
func (m *ReverseProxyModule) RegisterConfig(app modular.Application) error
RegisterConfig registers the module's configuration with the application. It also stores the provided app as a TenantApplication for later use with tenant-specific functionality.
func (*ReverseProxyModule) RegisterCustomEndpoint ¶
func (m *ReverseProxyModule) RegisterCustomEndpoint(pattern string, mapping EndpointMapping)
RegisterCustomEndpoint adds a custom endpoint with a response transformer. This provides the most flexibility for combining and transforming responses from multiple backends using custom logic.
func (*ReverseProxyModule) RequiresServices ¶
func (m *ReverseProxyModule) RequiresServices() []modular.ServiceDependency
RequiresServices returns the services required by this module. The reverseproxy module requires a service that implements the routerService interface to register routes with, and optionally a http.Client.
func (*ReverseProxyModule) SetHttpClient ¶
func (m *ReverseProxyModule) SetHttpClient(client *http.Client)
SetHttpClient overrides the default HTTP client used by the module. This method can be used to customize the HTTP client with advanced settings such as custom timeouts, transport configurations, or for testing purposes. It should be called before the Start method.
Note: This also updates the transport for all existing reverse proxies. This method is retained for backward compatibility, but using the httpclient service is recommended for new code.