Files
astra-api-gateway/config/config.go
2023-07-24 16:00:56 +03:00

48 lines
904 B
Go

package config
import (
"os"
)
type MSHostsConfig struct {
UsersHost string
StoreHost string
EventsHost string
PersonsHost string
}
type ServerConfig struct {
Port string
JWTSecret string
}
type Config struct {
MSHosts MSHostsConfig
Server ServerConfig
}
func New() *Config {
return &Config{
MSHosts: MSHostsConfig{
UsersHost: getEnv("ASTRA-USERS", "http://localhost:8082"),
StoreHost: getEnv("ASTRA-FILE-STORAGE", "http://localhost:8081"),
EventsHost: getEnv("ASTRA-EVENTS", "http://localhost:8083"),
PersonsHost: getEnv("ASTRA-PESONAL-INFORMATION", "http://localhost:8083"),
},
Server: ServerConfig{
Port: getEnv("PORT", "8080"),
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()