feat: Enhance texture upload functionality and API response format
- Introduced a new upload endpoint for direct texture file uploads, allowing users to upload textures with validation for size and format. - Updated existing texture-related API responses to a standardized format, improving consistency across the application. - Refactored texture service methods to handle file uploads and reuse existing texture URLs based on hash checks. - Cleaned up Dockerfile and other files by removing unnecessary whitespace.
This commit is contained in:
@@ -10,11 +10,14 @@ import (
|
||||
func CORS() gin.HandlerFunc {
|
||||
// 获取配置,如果配置未初始化则使用默认值
|
||||
var allowedOrigins []string
|
||||
var isTestEnv bool
|
||||
if cfg, err := config.GetConfig(); err == nil {
|
||||
allowedOrigins = cfg.Security.AllowedOrigins
|
||||
isTestEnv = cfg.IsTestEnvironment()
|
||||
} else {
|
||||
// 默认允许所有来源(向后兼容)
|
||||
allowedOrigins = []string{"*"}
|
||||
isTestEnv = false
|
||||
}
|
||||
|
||||
return gin.HandlerFunc(func(c *gin.Context) {
|
||||
@@ -22,7 +25,8 @@ func CORS() gin.HandlerFunc {
|
||||
|
||||
// 检查是否允许该来源
|
||||
allowOrigin := "*"
|
||||
if len(allowedOrigins) > 0 && allowedOrigins[0] != "*" {
|
||||
// 测试环境下强制使用 *,否则按配置处理
|
||||
if !isTestEnv && len(allowedOrigins) > 0 && allowedOrigins[0] != "*" {
|
||||
allowOrigin = ""
|
||||
for _, allowed := range allowedOrigins {
|
||||
if allowed == origin || allowed == "*" {
|
||||
|
||||
Reference in New Issue
Block a user