Files
astra-api-gateway/config/config.go
2023-06-30 17:13:46 +03:00

44 lines
658 B
Go

package config
import (
"os"
)
type MSHostsConfig struct {
UsersHost string
StoreHost string
}
type ServerConfig struct {
Port string
JWTSecret string
}
type Config struct {
MSHosts MSHostsConfig
Server ServerConfig
}
func New() *Config {
return &Config{
MSHosts: MSHostsConfig{
UsersHost: getEnv("USERS_HOST", ""),
StoreHost: getEnv("STORE_HOST", ""),
},
Server: ServerConfig{
Port: getEnv("PORT", ""),
JWTSecret: getEnv("JWT_SECRET", "secret"),
},
}
}
func getEnv(key string, defaultVal string) string {
if value, exists := os.LookupEnv(key); exists {
return value
}
return defaultVal
}
var Env = New()