2026-06-14 11:33:31 +08:00
|
|
|
package config
|
|
|
|
|
|
|
|
|
|
import "os"
|
|
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
|
Port string
|
|
|
|
|
DBDSN string
|
|
|
|
|
InternalServiceKey string
|
|
|
|
|
PurchaserServiceURL string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Load() *Config {
|
|
|
|
|
return &Config{
|
|
|
|
|
Port: getEnv("PORT", "8084"),
|
2026-06-17 23:16:17 +08:00
|
|
|
DBDSN: getEnv("DB_DSN", ""),
|
2026-06-14 11:33:31 +08:00
|
|
|
InternalServiceKey: getEnv("INTERNAL_SERVICE_KEY", "dev-internal-key"),
|
|
|
|
|
PurchaserServiceURL: getEnv("PURCHASER_SERVICE_URL", "http://localhost:8082"),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func getEnv(key, fallback string) string {
|
|
|
|
|
if v := os.Getenv(key); v != "" {
|
|
|
|
|
return v
|
|
|
|
|
}
|
|
|
|
|
return fallback
|
|
|
|
|
}
|