chore: align forest AI development setup

This commit is contained in:
2026-07-21 20:07:51 +08:00
parent b7de3c28b6
commit d2ef10763c
7 changed files with 150 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
package config
import (
"fmt"
"os"
"path/filepath"
"strings"
@@ -45,5 +46,18 @@ func LoadFromDir(configDir string) (Config, error) {
if cfg.MaxUploadBytes <= 0 {
cfg.MaxUploadBytes = 32 << 20
}
if strings.TrimSpace(cfg.StorageDir) == "" {
return Config{}, fmt.Errorf("storage_dir must not be empty")
}
hasAllowedOrigin := false
for _, origin := range cfg.AllowedOrigins {
if strings.TrimSpace(origin) != "" {
hasAllowedOrigin = true
break
}
}
if !hasAllowedOrigin {
return Config{}, fmt.Errorf("allowed_origins must include at least one origin")
}
return cfg, nil
}