feat: initial gateway implementation
This commit is contained in:
39
pkg/config/config.go
Normal file
39
pkg/config/config.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Config holds application configuration
|
||||
type Config struct {
|
||||
HTTPPort string
|
||||
UDPPort string
|
||||
LogLevel string
|
||||
}
|
||||
|
||||
// Load loads configuration from file or environment variables
|
||||
func Load(configFile string) *Config {
|
||||
cfg := &Config{
|
||||
HTTPPort: getEnvOrDefault("HTTP_PORT", "3001"),
|
||||
UDPPort: getEnvOrDefault("UDP_PORT", "4210"),
|
||||
LogLevel: getEnvOrDefault("LOG_LEVEL", "info"),
|
||||
}
|
||||
|
||||
// TODO: Load from config file if provided
|
||||
if configFile != "" {
|
||||
log.WithField("file", configFile).Info("Loading configuration from file")
|
||||
// Implement file loading here if needed
|
||||
}
|
||||
|
||||
return cfg
|
||||
}
|
||||
|
||||
// getEnvOrDefault returns environment variable value or default
|
||||
func getEnvOrDefault(key, defaultValue string) string {
|
||||
if value := os.Getenv(key); value != "" {
|
||||
return value
|
||||
}
|
||||
return defaultValue
|
||||
}
|
||||
Reference in New Issue
Block a user