Add management API endpoints

This commit is contained in:
DullJZ
2025-11-04 19:57:02 +08:00
parent 529ee8fe55
commit ffc21aa49c
6 changed files with 268 additions and 4 deletions
+12
View File
@@ -16,6 +16,7 @@ type Config struct {
Balancer BalancerConfig `yaml:"balancer"`
Metrics MetricsConfig `yaml:"metrics"`
S3API S3APIConfig `yaml:"s3api"`
API APIConfig `yaml:"api"`
}
// ServerConfig 服务器配置
@@ -75,6 +76,12 @@ type S3APIConfig struct {
Host string `yaml:"host"` // 用于签名验证的Host(为空则使用请求的Host)
}
// APIConfig 管理API配置
type APIConfig struct {
Enabled bool `yaml:"enabled"` // 是否启用管理API
Token string `yaml:"token"` // API访问令牌
}
// DatabaseConfig 数据库配置
type DatabaseConfig struct {
Type string `yaml:"type"` // 数据库类型: sqlite, mysql, postgres
@@ -179,6 +186,11 @@ func (c *Config) SetDefaults() {
if c.S3API.SecretKey == "" {
c.S3API.SecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
}
// 管理API默认值
if c.API.Token == "" {
c.API.Token = "your-secure-api-token-here"
}
}
// ParseMaxSize 解析最大容量字符串为字节