Files
astra-events/config/config.go
2023-08-01 16:48:54 +03:00

44 lines
861 B
Go

package config
import (
"os"
)
type ServerConfig struct {
Port string
ConnectionString string
}
type MSHosts struct {
UsersHost string
PersonsHost string
}
type Config struct {
Server ServerConfig
MSHosts MSHosts
}
func New() *Config {
return &Config{
Server: ServerConfig{
Port: getEnv("PORT", "8080"),
ConnectionString: getEnv("CONNECTION_STRING", "host=localhost user=astra_events password=password dbname=astra_events_db port=5432 sslmode=disable TimeZone=Europe/Moscow"),
},
MSHosts: MSHosts{
UsersHost: getEnv("ASTRA-USERS", "http://localhost:8083"),
PersonsHost: getEnv("ASTRA-PESONAL-INFORMATION", "http://localhost:8082"),
},
}
}
func getEnv(key string, defaultVal string) string {
if value, exists := os.LookupEnv(key); exists {
return value
}
return defaultVal
}
var Env = New()