package config import ( "os" "gopkg.in/yaml.v3" ) type Config struct { Site SiteConfig `yaml:"site"` Security SecurityConfig `yaml:"security"` Upload UploadConfig `yaml:"upload"` Storage StorageConfig `yaml:"storage"` APIToken APITokenConfig `yaml:"api_token"` Database DatabaseConfig `yaml:"database"` } type SiteConfig struct { Name string `yaml:"name"` Description string `yaml:"description"` } type SecurityConfig struct { AdminPasswordHash string `yaml:"admin_password_hash"` PickupCodeLength int `yaml:"pickup_code_length"` PickupFailLimit int `yaml:"pickup_fail_limit"` JWTSecret string `yaml:"jwt_secret"` } type UploadConfig struct { MaxFileSizeMB int64 `yaml:"max_file_size_mb"` MaxBatchFiles int `yaml:"max_batch_files"` MaxRetentionDays int `yaml:"max_retention_days"` } type StorageConfig struct { Type string `yaml:"type"` Local struct { Path string `yaml:"path"` } `yaml:"local"` WebDAV struct { URL string `yaml:"url"` Username string `yaml:"username"` Password string `yaml:"password"` Root string `yaml:"root"` } `yaml:"webdav"` S3 struct { Endpoint string `yaml:"endpoint"` Region string `yaml:"region"` AccessKey string `yaml:"access_key"` SecretKey string `yaml:"secret_key"` Bucket string `yaml:"bucket"` UseSSL bool `yaml:"use_ssl"` } `yaml:"s3"` } type APITokenConfig struct { Enabled bool `yaml:"enabled"` AllowAdminAPI bool `yaml:"allow_admin_api"` MaxTokens int `yaml:"max_tokens"` } type DatabaseConfig struct { Path string `yaml:"path"` } var GlobalConfig *Config func LoadConfig(path string) error { data, err := os.ReadFile(path) if err != nil { return err } var cfg Config if err := yaml.Unmarshal(data, &cfg); err != nil { return err } GlobalConfig = &cfg return nil }