merch-api/config/config.go

50 lines
864 B
Go
Raw Normal View History

2026-02-23 18:34:26 +03:00
package config
import "time"
type Config struct {
App App
Http Http
TasksSource TasksSource
}
type App struct {
LogLvl string
2026-02-23 19:33:36 +03:00
Mode string
2026-02-23 18:34:26 +03:00
}
type Http struct {
Host string
Port string
2026-02-23 19:33:36 +03:00
Prefix string
2026-02-23 18:34:26 +03:00
GinMode string
}
type TasksSource struct {
Host string
Port string
Timeout time.Duration
}
func NewConfig() Config {
return Config{
App: App{
LogLvl: getEnv("APP_LOG_LVL", "debug"),
2026-02-23 19:33:36 +03:00
Mode: getEnv("APP_MODE", "dev"),
2026-02-23 18:34:26 +03:00
},
Http: Http{
Host: getEnv("HTTP_HOST", "0.0.0.0"),
2026-02-23 19:33:36 +03:00
Port: getEnv("HTTP_PORT", "41083"),
Prefix: getEnv("HTTP_PREFIX", "/api/v2"),
2026-02-23 18:34:26 +03:00
GinMode: getEnv("GIN_MODE", "dev"),
},
TasksSource: TasksSource{
Host: getEnv("TASK_API_HOST", "127.0.0.1"),
Port: getEnv("TASK_API_PORT", "61000"),
Timeout: getEnvSeconds("TASK_SOURCE_TIMEOUT_SECONDS", 60),
},
}
}