## 🛡️ 新增功能 - 实现完整的CORS中间件,支持开发/生产环境配置 - 实现请求日志中间件,完整的请求生命周期记录 - 实现全局错误处理中间件,统一错误响应格式 - 创建中间件管理器,支持链式中间件和配置管理 ## 🔧 技术改进 - 更新配置系统支持中间件配置 - 修复go-zero日志API兼容性问题 - 创建完整的中间件测试用例 - 编译测试通过,功能完整可用 ## 📊 进度提升 - 项目总进度从42.5%提升至50.0% - 中优先级任务完成率达55% - 3个中优先级任务同时完成 ## 🎯 完成的任务 14. 实现 CORS 中间件 16. 实现请求日志中间件 17. 完善全局错误处理 Co-authored-by: Claude Code <claude@anthropic.com>
34 lines
898 B
Go
34 lines
898 B
Go
package config
|
|
|
|
import (
|
|
"github.com/zeromicro/go-zero/rest"
|
|
"photography-backend/pkg/utils/database"
|
|
)
|
|
|
|
type Config struct {
|
|
rest.RestConf
|
|
Database database.Config `json:"database"`
|
|
Auth AuthConfig `json:"auth"`
|
|
FileUpload FileUploadConfig `json:"file_upload"`
|
|
Middleware MiddlewareConfig `json:"middleware"`
|
|
}
|
|
|
|
type AuthConfig struct {
|
|
AccessSecret string `json:"access_secret"`
|
|
AccessExpire int64 `json:"access_expire"`
|
|
}
|
|
|
|
type FileUploadConfig struct {
|
|
MaxSize int64 `json:"max_size"`
|
|
UploadDir string `json:"upload_dir"`
|
|
AllowedTypes []string `json:"allowed_types"`
|
|
}
|
|
|
|
type MiddlewareConfig struct {
|
|
EnableCORS bool `json:"enable_cors"`
|
|
EnableLogger bool `json:"enable_logger"`
|
|
EnableErrorHandle bool `json:"enable_error_handle"`
|
|
CORSOrigins []string `json:"cors_origins"`
|
|
LogLevel string `json:"log_level"`
|
|
}
|