recovery

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2025 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...Option) rex.Middleware

New creates a new recovery middleware with the given options

Types

type Logger added in v1.5.0

type Logger interface {
	Printf(format string, v ...any)
}

Logger interface for custom logging

type Option added in v1.5.0

type Option func(*RecoveryConfig)

Option defines a function type for configuring RecoveryConfig

func WithErrorHandler added in v1.5.0

func WithErrorHandler(handler func(c *rex.Context, err error)) Option

WithErrorHandler sets a custom error handler

func WithExposeErrors added in v1.5.0

func WithExposeErrors(expose bool) Option

WithExposeErrors configures whether to expose error details to clients

func WithLogger added in v1.5.0

func WithLogger(logger Logger) Option

WithLogger sets a custom logger

func WithProductionMessage added in v1.5.0

func WithProductionMessage(message string) Option

WithProductionMessage sets a custom error message for production

func WithStackTrace added in v1.5.0

func WithStackTrace(enabled bool) Option

WithStackTrace configures whether to log stack traces

type RecoveryConfig added in v1.5.0

type RecoveryConfig struct {
	// Whether to include stack trace in logs
	StackTrace bool

	// Custom error handler - if provided, it handles the error completely
	ErrorHandler func(c *rex.Context, err error)

	// Custom logger - if not provided, uses standard log package
	Logger Logger

	// Whether to send error details to client (disable in production)
	ExposeErrors bool

	// Custom error message for production
	ProductionMessage string
}

RecoveryConfig holds configuration for the recovery middleware

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL