add user service
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 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()
|
||||
Reference in New Issue
Block a user