Files
vectordns-server/internal/config/config.go
2026-02-24 13:44:34 -05:00

30 lines
513 B
Go

package config
import (
"os"
"strings"
)
type Config struct {
Port string
APIKey string
CORSOrigins []string
LogFormat string
}
func Load() *Config {
return &Config{
Port: getEnv("PORT", "8080"),
APIKey: getEnv("API_KEY", ""),
CORSOrigins: strings.Split(getEnv("CORS_ORIGINS", "http://localhost:3000"), ","),
LogFormat: getEnv("LOG_FORMAT", "text"),
}
}
func getEnv(key, fallback string) string {
if v := os.Getenv(key); v != "" {
return v
}
return fallback
}