proxy

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultHTTPClientTimeout is the default timeout for HTTP requests
	DefaultHTTPClientTimeout = 30 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigProvider

type ConfigProvider interface {
	GetGlobalProxyEnabled() bool
	GetGlobalProxyURL() string
	GetGlobalProxyUsername() string
	GetGlobalProxyPassword() string
	GetBotProxyEnabled(botType string) bool
	GetBotProxyURL(botType string) string
	GetBotProxyUsername(botType string) string
	GetBotProxyPassword(botType string) string
}

ConfigProvider provides proxy configuration to ProxyManager This avoids circular dependency between core and proxy packages

type Manager

type Manager interface {
	GetHTTPClient(botType string) (*http.Client, error)
	GetProxyURL(botType string) string
}

Manager defines the interface for proxy management This allows bot adapters to get HTTP clients with proxy configuration

type ProxyConfig

type ProxyConfig struct {
	Enabled  bool
	URL      string
	Username string
	Password string
}

ProxyConfig represents a proxy configuration

type ProxyManager

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

ProxyManager manages HTTP clients with proxy support It implements three-tier proxy priority: bot-level > global > environment variables

func NewProxyManager

func NewProxyManager(configProvider ConfigProvider) *ProxyManager

NewProxyManager creates a new ProxyManager instance

func (*ProxyManager) ClearCache

func (pm *ProxyManager) ClearCache()

ClearCache removes all cached HTTP clients Useful for configuration reloads or testing

func (*ProxyManager) GetHTTPClient

func (pm *ProxyManager) GetHTTPClient(botType string) (*http.Client, error)

GetHTTPClient returns an HTTP client for the specified bot type It caches clients to reuse connections and improve performance

func (*ProxyManager) GetProxyURL

func (pm *ProxyManager) GetProxyURL(botType string) string

GetProxyURL returns the proxy URL for the specified bot type Returns "env://HTTP_PROXY" if using environment variables

Jump to

Keyboard shortcuts

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