package middleware import ( "github.com/gofiber/fiber/v3" ) // Recovery 恢复中间件 func Recovery() fiber.Handler { return func(c fiber.Ctx) error { defer func() { if r := recover(); r != nil { c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{ "errors": []fiber.Map{ { "code": "INTERNAL_ERROR", "message": "Internal server error", }, }, }) } }() return c.Next() } }