image-storage/config/config.go

34 lines
589 B
Go
Raw Normal View History

2025-10-20 18:23:53 +03:00
package config
2025-10-25 17:41:04 +03:00
import "strings"
2025-10-20 18:23:53 +03:00
type Config struct {
App AppConfig
}
type AppConfig struct {
2025-10-20 22:21:55 +03:00
Host string
HttpPort string
2025-10-20 18:23:53 +03:00
GrpcPort string
2025-10-20 22:21:55 +03:00
Domain string
2025-10-22 21:34:17 +03:00
Volume string
2025-10-20 18:23:53 +03:00
LogLevel string
}
func NewConfig() *Config {
return &Config{
App: AppConfig{
2025-10-20 22:21:55 +03:00
Host: getEnv("HOST", ""),
HttpPort: getEnv("HTTP_PORT", ""),
2025-10-20 18:23:53 +03:00
GrpcPort: getEnv("GRPC_PORT", ""),
2025-10-25 17:41:04 +03:00
Domain: formatDomain(getEnv("DOMAIN", "")),
2025-10-22 21:34:17 +03:00
Volume: getEnv("VOLUME", ""),
2025-10-20 18:23:53 +03:00
LogLevel: getEnv("LOG_LEVEL", ""),
},
}
}
2025-10-25 17:41:04 +03:00
func formatDomain(domain string) string {
return strings.TrimRight(domain, "/")
}