Recovery
var DefaultRecoverConfig
var DefaultRecoverConfig = RecoverConfig{ StackSize: 4 << 10, // 4 KB DisableStackAll: false, DisablePrintStack: false,}Default configuration for the recovery middleware.
type RecoverConfig
type RecoverConfig struct { // Size of the stack to be printed. // Optional. Default value 4KB. StackSize int // DisableStackAll disables formatting stack traces of all other goroutines // into buffer after the trace for the current goroutine. // Optional. Default value is false. DisableStackAll bool // DisablePrintStack disables printing stack trace. // Optional. Default value as false. DisablePrintStack bool}Configuration struct for the recovery middleware.
func (RecoverConfig) ToMiddleware
func (config RecoverConfig) ToMiddleware() MiddlewareFuncConverts the RecoverConfig struct to a recovery middleware. This middleware can catch panic errors and return them.
func Recover
func Recover() MiddlewareFuncReturns a recovery middleware that can catch panic errors and return them, making it convenient for the program to provide them to the error handler.
func RecoverWithConfig
func RecoverWithConfig(config RecoverConfig) MiddlewareFuncReturns a recovery middleware with configuration.