Files
initpage/internal/config/config.go

35 lines
773 B
Go

package config
import (
"os"
)
type Config struct {
Port string
BasePath string
AppOrigin string
SessionSecret string
TurnstileSecret string
TurnstileSiteKey string
DBPath string
}
func Load() *Config {
return &Config{
Port: getEnv("PORT", "8080"),
BasePath: getEnv("BASE_PATH", "/initpage"),
AppOrigin: getEnv("APP_ORIGIN", "https://apps.weltonmoura.com.br"),
SessionSecret: getEnv("SESSION_SECRET", "dev-secret-change-me"),
TurnstileSecret: getEnv("TURNSTILE_SECRET", ""),
TurnstileSiteKey: getEnv("TURNSTILE_SITEKEY", ""),
DBPath: getEnv("DB_PATH", "./data/initpage.db"),
}
}
func getEnv(key, def string) string {
if v := os.Getenv(key); v != "" {
return v
}
return def
}