Initial commit: Go DNS microservice boilerplate

This commit is contained in:
Aiden Smith
2026-02-24 13:44:34 -05:00
commit 247f81d616
13 changed files with 451 additions and 0 deletions

29
internal/config/config.go Normal file
View File

@@ -0,0 +1,29 @@
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
}