config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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

func LoadConfig() (*Config, error)

LoadConfig loads configuration from the default path using Viper

func LoadConfigFromDir

func LoadConfigFromDir(dir string) (*Config, error)

LoadConfigFromDir loads configuration from a specific directory using Viper

func LoadConfigFromFile

func LoadConfigFromFile(filePath string) (*Config, error)

LoadConfigFromFile loads configuration from a specific file path

func LoadOrCreateConfig

func LoadOrCreateConfig() (*Config, error)

LoadOrCreateConfig loads existing config or creates a new one with defaults

func (*Config) AddEnvironment

func (c *Config) AddEnvironment(name string, vars map[string]string) error

AddEnvironment adds a new environment

func (*Config) BindFlags

func (c *Config) BindFlags(v *viper.Viper)

BindFlags binds cobra flags to viper configuration

func (*Config) ExportToJSON

func (c *Config) ExportToJSON() (string, error)

ExportToJSON exports the config as JSON string

func (*Config) GetEnvironment

func (c *Config) GetEnvironment() map[string]string

GetEnvironment returns the environment variables for the current environment

func (*Config) GetEnvironmentVariable

func (c *Config) GetEnvironmentVariable(env, name string) (string, bool)

GetEnvironmentVariable gets a variable from an environment

func (*Config) GetViper

func (c *Config) GetViper() *viper.Viper

GetViper returns the underlying viper instance

func (*Config) ListEnvironments

func (c *Config) ListEnvironments() []string

ListEnvironments returns a list of available environments

func (*Config) Reload

func (c *Config) Reload() error

Reload reloads the configuration from the config file

func (*Config) RemoveEnvironment

func (c *Config) RemoveEnvironment(name string) error

RemoveEnvironment removes an environment

func (*Config) Save

func (c *Config) Save() error

Save saves the configuration to file

func (*Config) SetEnvironment

func (c *Config) SetEnvironment(name string) error

SetEnvironment sets the current environment

func (*Config) SetEnvironmentVariable

func (c *Config) SetEnvironmentVariable(env, name, value string) error

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

Jump to

Keyboard shortcuts

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