config.go 555 B

12345678910111213141516171819202122232425262728293031323334
  1. package config
  2. import "os"
  3. // Config holds application configuration
  4. type Config struct {
  5. Port string
  6. UploadsDir string
  7. DBPath string
  8. }
  9. // Load loads configuration from environment variables
  10. func Load() *Config {
  11. port := os.Getenv("PORT")
  12. if port == "" {
  13. port = "8080"
  14. }
  15. uploadsDir := os.Getenv("UPLOADS_DIR")
  16. if uploadsDir == "" {
  17. uploadsDir = "uploads"
  18. }
  19. dbPath := os.Getenv("DB_PATH")
  20. if dbPath == "" {
  21. dbPath = "data/bolt.db"
  22. }
  23. return &Config{
  24. Port: port,
  25. UploadsDir: uploadsDir,
  26. DBPath: dbPath,
  27. }
  28. }