mirror of
https://github.com/DevVoxel/vectordns-server.git
synced 2026-02-27 01:40:12 +00:00
30 lines
513 B
Go
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
|
|
}
|