新增配置管理功能及多存储支持
- 添加管理员端 API,用于获取和更新完整配置。 - 添加公共端 API,用于获取非敏感配置信息。 - 增加本地存储(LocalStorage)、S3(S3Storage)、和 WebDAV(WebDAVStorage)存储类型的实现。 - 支持热更新存储配置和保存配置文件至磁盘。 - 更新 Swagger 文档以包含新接口定义。
This commit is contained in:
@@ -43,13 +43,15 @@ func InitDB() {
|
||||
fmt.Println("Database initialized and migrated.")
|
||||
|
||||
// 初始化存储
|
||||
initStorage()
|
||||
if err := ReloadStorage(); err != nil {
|
||||
log.Fatalf("Failed to initialize storage: %v", err)
|
||||
}
|
||||
|
||||
// 初始化管理员 (如果不存在)
|
||||
initAdmin()
|
||||
}
|
||||
|
||||
func initStorage() {
|
||||
func ReloadStorage() error {
|
||||
storageType := config.GlobalConfig.Storage.Type
|
||||
switch storageType {
|
||||
case "local":
|
||||
@@ -61,13 +63,14 @@ func initStorage() {
|
||||
cfg := config.GlobalConfig.Storage.S3
|
||||
s3Storage, err := storage.NewS3Storage(context.Background(), cfg.Endpoint, cfg.Region, cfg.AccessKey, cfg.SecretKey, cfg.Bucket, cfg.UseSSL)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to initialize S3 storage: %v", err)
|
||||
return err
|
||||
}
|
||||
storage.GlobalStorage = s3Storage
|
||||
default:
|
||||
log.Fatalf("Unsupported storage type: %s", storageType)
|
||||
return fmt.Errorf("unsupported storage type: %s", storageType)
|
||||
}
|
||||
fmt.Printf("Storage initialized with type: %s\n", storageType)
|
||||
return nil
|
||||
}
|
||||
|
||||
func initAdmin() {
|
||||
|
||||
Reference in New Issue
Block a user