Documentation
¶
Overview ¶
Package config provides config utilities.
Index ¶
- func IsProduction(env string) bool
- func SplitCSV(input string) []string
- type Config
- type Loader
- func (l *Loader) Bool(key string, def bool) bool
- func (l *Loader) CSV(key string) []string
- func (l *Loader) Duration(key string, def time.Duration) time.Duration
- func (l *Loader) Err() error
- func (l *Loader) Int(key string, def int) int
- func (l *Loader) Require(key string) string
- func (l *Loader) String(key, def string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsProduction ¶
IsProduction returns true when env is production-like.
Types ¶
type Config ¶
type Config struct {
Addr string `env:"API_ADDR"` // host:port|:port
DatabaseURL string `env:"DATABASE_URL"` // required
LogLevel string `env:"LOG_LEVEL"` // debug|info|warn|error
MigrateOnStart bool `env:"MIGRATE_ON_START"` // true|false
MigrationsDir string `env:"MIGRATIONS_DIR"` // plain - means use embedded
Env string `env:"ENV"` // development|staging|production
// Optional rate-limit bypass for test/dev environments.
RateLimitSkipEnabled bool `env:"RATE_LIMIT_SKIP_ENABLED"` // true|false
RateLimitSkipHeader string `env:"RATE_LIMIT_SKIP_HEADER"` // header name
RateLimitAllowDangerousDevBypasses bool `env:"RATE_LIMIT_ALLOW_DANGEROUS_DEV_BYPASSES"` // true|false
}
Config captures application configuration loaded from environment variables.
func LoadFromEnv ¶
LoadFromEnv loads config from environment using an optional loader.
func MustLoadFromEnv ¶
func MustLoadFromEnv() Config
MustLoadFromEnv loads config or panics if required values are missing.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader reads env vars with defaults and aggregates errors.
func NewLoader ¶
func NewLoader() *Loader
NewLoader creates a loader backed by the default env adapter.
Click to show internal directories.
Click to hide internal directories.