Documentation
¶
Overview ¶
Package config provides application configuration management with support for JSON config files, viper integration, and hot-reloading.
Index ¶
- func SetViperDefaults(v *viper.Viper)
- type CertificateConfig
- type Config
- func (c *Config) AddEnvironment(name string, vars map[string]string) error
- func (c *Config) BindFlags(v *viper.Viper)
- func (c *Config) ExportToJSON() (string, error)
- func (c *Config) GetEnvironment() map[string]string
- func (c *Config) GetEnvironmentVariable(env, name string) (string, bool)
- func (c *Config) GetViper() *viper.Viper
- func (c *Config) ListEnvironments() []string
- func (c *Config) Reload() error
- func (c *Config) RemoveEnvironment(name string) error
- func (c *Config) Save() error
- func (c *Config) SetEnvironment(name string) error
- func (c *Config) SetEnvironmentVariable(env, name, value string) error
- func (c *Config) ToClientConfig() *client.ClientConfig
- func (c *Config) WatchConfig(onChange func())
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetViperDefaults ¶ added in v0.2.10
SetViperDefaults sets default values in a viper instance based on DefaultConfig. This should be used by cmd/root.go to avoid duplicating default values.
Types ¶
type CertificateConfig ¶
type CertificateConfig struct {
Cert string `json:"cert,omitempty" mapstructure:"cert"`
Key string `json:"key,omitempty" mapstructure:"key"`
PFX string `json:"pfx,omitempty" mapstructure:"pfx"`
Passphrase string `json:"passphrase,omitempty" mapstructure:"passphrase"`
}
CertificateConfig holds certificate paths
type Config ¶
type Config struct {
// HTTP client settings
FollowRedirects bool `json:"followRedirect" mapstructure:"followRedirect"`
TimeoutMs int `json:"timeoutInMilliseconds" mapstructure:"timeoutInMilliseconds"`
RememberCookies bool `json:"rememberCookiesForSubsequentRequests" mapstructure:"rememberCookiesForSubsequentRequests"`
// Default headers
DefaultHeaders map[string]string `json:"defaultHeaders" mapstructure:"defaultHeaders"`
// Environment variables
EnvironmentVariables map[string]map[string]string `json:"environmentVariables" mapstructure:"environmentVariables"`
// Current environment
CurrentEnvironment string `json:"currentEnvironment" mapstructure:"currentEnvironment"`
// SSL settings
InsecureSSL bool `json:"insecureSSL" mapstructure:"insecureSSL"`
ProxyStrictSSL bool `json:"proxyStrictSSL" mapstructure:"proxyStrictSSL"`
// Proxy settings
Proxy string `json:"proxy" mapstructure:"proxy"`
ExcludeHostsForProxy []string `json:"excludeHostsForProxy" mapstructure:"excludeHostsForProxy"`
// Certificates
Certificates map[string]CertificateConfig `json:"certificates" mapstructure:"certificates"`
// Display settings
PreviewOption string `json:"previewOption" mapstructure:"previewOption"` // full, headers, body, exchange
ShowColors bool `json:"showColors" mapstructure:"showColors"`
// contains filtered or unexported fields
}
Config represents the application configuration
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a new config with default values
func LoadConfig ¶
LoadConfig loads configuration from the default path using Viper
func LoadConfigFromDir ¶
LoadConfigFromDir loads configuration from a specific directory using Viper
func LoadConfigFromFile ¶
LoadConfigFromFile loads configuration from a specific file path
func LoadOrCreateConfig ¶
LoadOrCreateConfig loads existing config or creates a new one with defaults
func (*Config) AddEnvironment ¶
AddEnvironment adds a new environment
func (*Config) ExportToJSON ¶
ExportToJSON exports the config as JSON string
func (*Config) GetEnvironment ¶
GetEnvironment returns the environment variables for the current environment
func (*Config) GetEnvironmentVariable ¶
GetEnvironmentVariable gets a variable from an environment
func (*Config) ListEnvironments ¶
ListEnvironments returns a list of available environments
func (*Config) RemoveEnvironment ¶
RemoveEnvironment removes an environment
func (*Config) SetEnvironment ¶
SetEnvironment sets the current environment
func (*Config) SetEnvironmentVariable ¶
SetEnvironmentVariable sets a variable in an environment
func (*Config) ToClientConfig ¶
func (c *Config) ToClientConfig() *client.ClientConfig
ToClientConfig converts Config to client.ClientConfig
func (*Config) WatchConfig ¶
func (c *Config) WatchConfig(onChange func())
WatchConfig enables live config reloading