mirror of
https://github.com/gofiber/fiber.git
synced 2025-05-07 16:19:43 +00:00
Fix typos, and make docs more consistent This fixes several typos in the ISSUE_TEMPLATES, as well as improve their readability, also makes the documentation markdowns more consistent
1.4 KiB
1.4 KiB
id, title
id | title |
---|---|
recover | Recover |
Recover middleware for Fiber that recovers from panics anywhere in the stack chain and handles the control to the centralized ErrorHandler.
Signatures
func New(config ...Config) fiber.Handler
Examples
Import the middleware package that is part of the Fiber web framework
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/recover"
)
After you initiate your Fiber app, you can use the following possibilities:
// Initialize default config
app.Use(recover.New())
// This panic will be caught by the middleware
app.Get("/", func(c *fiber.Ctx) error {
panic("I'm an error")
})
Config
// Config defines the config for middleware.
type Config struct {
// Next defines a function to skip this middleware when returned true.
//
// Optional. Default: nil
Next func(c *fiber.Ctx) bool
// EnableStackTrace enables handling stack trace
//
// Optional. Default: false
EnableStackTrace bool
// StackTraceHandler defines a function to handle stack trace
//
// Optional. Default: defaultStackTraceHandler
StackTraceHandler func(c *fiber.Ctx, e interface{})
}
Default Config
var ConfigDefault = Config{
Next: nil,
EnableStackTrace: false,
StackTraceHandler: defaultStackTraceHandler,
}