2026-06-14 11:33:31 +08:00
|
|
|
package config
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os"
|
|
|
|
|
"strings"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
|
Port string
|
|
|
|
|
JWTSecret string
|
|
|
|
|
AuthServiceURL string
|
|
|
|
|
PurchaserServiceURL string
|
|
|
|
|
TextileServiceURL string
|
|
|
|
|
WashingServiceURL string
|
2026-07-04 02:34:20 +00:00
|
|
|
MuyuGatewayURL string
|
2026-06-14 11:33:31 +08:00
|
|
|
AllowOrigins []string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Load() *Config {
|
|
|
|
|
return &Config{
|
|
|
|
|
Port: getEnv("PORT", "8080"),
|
2026-06-17 23:16:17 +08:00
|
|
|
JWTSecret: getEnv("JWT_SECRET", ""),
|
2026-06-14 11:33:31 +08:00
|
|
|
AuthServiceURL: getEnv("AUTH_SERVICE_URL", "http://localhost:8081"),
|
|
|
|
|
PurchaserServiceURL: getEnv("PURCHASER_SERVICE_URL", "http://localhost:8082"),
|
|
|
|
|
TextileServiceURL: getEnv("TEXTILE_SERVICE_URL", "http://localhost:8083"),
|
|
|
|
|
WashingServiceURL: getEnv("WASHING_SERVICE_URL", "http://localhost:8084"),
|
2026-07-04 02:34:20 +00:00
|
|
|
MuyuGatewayURL: getEnv("MUYU_GATEWAY_URL", "http://localhost:8888"),
|
2026-06-14 11:33:31 +08:00
|
|
|
AllowOrigins: strings.Split(getEnv("ALLOW_ORIGINS", "*"), ","),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func getEnv(key, fallback string) string {
|
|
|
|
|
if v := os.Getenv(key); v != "" {
|
|
|
|
|
return v
|
|
|
|
|
}
|
|
|
|
|
return fallback
|
|
|
|
|
}
|