50 lines
1.0 KiB
Go
50 lines
1.0 KiB
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
)
|
|
|
|
type MSHostsConfig struct {
|
|
UsersHost string
|
|
StoreHost string
|
|
EventsHost string
|
|
PersonsHost string
|
|
MedicalCardHost 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"),
|
|
MedicalCardHost: getEnv("MEDICAL-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()
|