33 lines
463 B
Go
33 lines
463 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
)
|
|
|
|
type Config struct {
|
|
Port int
|
|
Mode string
|
|
MaxFileSize int64 // bytes
|
|
}
|
|
|
|
func Load() *Config {
|
|
cfg := &Config{
|
|
Port: 8080,
|
|
Mode: "debug",
|
|
MaxFileSize: 10 << 20, // 10MB
|
|
}
|
|
|
|
if port := os.Getenv("GEN2D_PORT"); port != "" {
|
|
if p, err := strconv.Atoi(port); err == nil {
|
|
cfg.Port = p
|
|
}
|
|
}
|
|
|
|
if mode := os.Getenv("GEN2D_MODE"); mode != "" {
|
|
cfg.Mode = mode
|
|
}
|
|
|
|
return cfg
|
|
}
|