wip: oci image management
This commit is contained in:
24
internal/middleware/recovery.go
Normal file
24
internal/middleware/recovery.go
Normal file
@@ -0,0 +1,24 @@
|
||||
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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user