fix gitea workflow path and runner label
Build docker and publish / build (20.15.1) (push) Failing after 8m21s

This commit is contained in:
2026-03-04 06:33:14 -08:00
parent 6c8f22adc8
commit a01570b59d
22 changed files with 1153 additions and 92 deletions
@@ -0,0 +1,25 @@
package middleware
import (
"context"
"strings"
"github.com/gin-gonic/gin"
"github.com/perfect-panel/server/internal/svc"
"github.com/perfect-panel/server/pkg/apiversion"
"github.com/perfect-panel/server/pkg/constant"
)
func ApiVersionMiddleware(_ *svc.ServiceContext) func(c *gin.Context) {
return func(c *gin.Context) {
rawVersion := strings.TrimSpace(c.GetHeader("api-header"))
useLatest := apiversion.UseLatest(rawVersion, apiversion.DefaultThreshold)
ctx := context.WithValue(c.Request.Context(), constant.CtxKeyAPIVersionUseLatest, useLatest)
ctx = context.WithValue(ctx, constant.CtxKeyAPIHeaderRaw, rawVersion)
c.Request = c.Request.WithContext(ctx)
c.Set("api_header", rawVersion)
c.Next()
}
}
+1 -1
View File
@@ -15,7 +15,7 @@ func CorsMiddleware(c *gin.Context) {
}
// c.Writer.Header().Set("Access-Control-Allow-Origin", c.Request.Host)
c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE, UPDATE")
c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Origin, X-CSRF-Token, Authorization, AccessToken, Token, Range")
c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Origin, X-CSRF-Token, Authorization, AccessToken, Token, Range, api-header")
c.Writer.Header().Set("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers")
c.Writer.Header().Set("Access-Control-Allow-Credentials", "true")
c.Writer.Header().Set("Access-Control-Max-Age", "172800")
+3
View File
@@ -70,6 +70,9 @@ func LoggerMiddleware(svc *svc.ServiceContext) func(c *gin.Context) {
Value: c.Request.UserAgent(),
},
}
if apiHeader, ok := c.Get("api_header"); ok {
logs = append(logs, logger.Field("api_header", apiHeader))
}
if c.Errors.Last() != nil {
var e *xerr.CodeError
var errMessage string