forked from mtusi2026/mtusi2026lab3
feat: полная реализация
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package config
|
||||
|
||||
import "os"
|
||||
|
||||
type Config struct {
|
||||
InstanceID string
|
||||
Port string
|
||||
DatabaseURL string
|
||||
}
|
||||
|
||||
func Load() *Config {
|
||||
cfg := &Config{
|
||||
InstanceID: os.Getenv("APP_INSTANCE_ID"),
|
||||
Port: os.Getenv("APP_PORT"),
|
||||
DatabaseURL: os.Getenv("DATABASE_URL"),
|
||||
}
|
||||
if cfg.InstanceID == "" {
|
||||
cfg.InstanceID = "api"
|
||||
}
|
||||
if cfg.Port == "" {
|
||||
cfg.Port = "8080"
|
||||
}
|
||||
if cfg.DatabaseURL == "" {
|
||||
panic("APP_INSTANCE_ID/APP_PORT optional; DATABASE_URL is required")
|
||||
}
|
||||
return cfg
|
||||
}
|
||||
Reference in New Issue
Block a user