42 lines
600 B
Go
42 lines
600 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
)
|
|
|
|
type MSHostsConfig struct {
|
|
UsersHost 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", ""),
|
|
},
|
|
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()
|