feat(config): read a flag in .env to set or not json output

This commit is contained in:
2025-11-21 13:11:16 +01:00
parent 79e072fe6b
commit f49bea4138

View File

@@ -15,6 +15,7 @@ type Config struct {
SMTP SMTPConfig
App AppConfig
RateLimit RateLimitConfig
CLI CLIConfig
LogDir string
PIDDir string
}
@@ -81,6 +82,10 @@ type RateLimitConfig struct {
TrustProxyHeaders bool
}
type CLIConfig struct {
JSONOutputDefault bool
}
func Load() (*Config, error) {
config := &Config{
Database: DatabaseConfig{
@@ -137,6 +142,9 @@ func Load() (*Config, error) {
MetricsLimit: getEnvAsInt("RATE_LIMIT_METRICS", 20),
TrustProxyHeaders: getEnvAsBool("RATE_LIMIT_TRUST_PROXY", false),
},
CLI: CLIConfig{
JSONOutputDefault: getEnvAsBool("CLI_JSON_OUTPUT", false),
},
LogDir: getEnv("LOG_DIR", "/var/log/"),
PIDDir: getEnv("PID_DIR", "/run"),
}