chore(init): 初始化解忧商行项目并完成 Phase 0 基座

This commit is contained in:
yml2213
2026-10-30 11:46:10 +08:00
commit 8d9481c251
689 changed files with 138703 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
package middleware
import (
"fmt"
"net/http"
"runtime/debug"
"hfb_sys/backend/pkg/response"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
const contextPanicStack = "panic_stack"
func Recovery(_ *zap.Logger) gin.HandlerFunc {
return func(c *gin.Context) {
defer func() {
if recovered := recover(); recovered != nil {
err := fmt.Errorf("panic: %v", recovered)
_ = c.Error(err)
c.Set(contextPanicStack, string(debug.Stack()))
if !c.Writer.Written() {
response.Error(c, http.StatusInternalServerError, "internal_error", "服务暂时不可用")
}
c.Abort()
}
}()
c.Next()
}
}