first commit
This commit is contained in:
41
config/config.go
Normal file
41
config/config.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
type ServerConfig struct {
|
||||
Port string
|
||||
ConnectionString string
|
||||
}
|
||||
|
||||
type MSHosts struct {
|
||||
UsersHost string
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Server ServerConfig
|
||||
MSHosts MSHosts
|
||||
}
|
||||
|
||||
func New() *Config {
|
||||
return &Config{
|
||||
Server: ServerConfig{
|
||||
Port: getEnv("PORT", "8080"),
|
||||
ConnectionString: getEnv("CONNECTION_STRING", "test.db"),
|
||||
},
|
||||
MSHosts: MSHosts{
|
||||
UsersHost: getEnv("ASTRA-USERS", "http://localhost:8082"),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func getEnv(key string, defaultVal string) string {
|
||||
if value, exists := os.LookupEnv(key); exists {
|
||||
return value
|
||||
}
|
||||
|
||||
return defaultVal
|
||||
}
|
||||
|
||||
var Env = New()
|
||||
Reference in New Issue
Block a user