recover

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package recover provides panic recovery middleware for the aarv framework.

It catches panics in downstream handlers, logs the stack trace, and returns a 500 JSON error response instead of crashing the server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(config ...Config) aarv.Middleware

New creates a panic recovery middleware with optional configuration. If no config is provided, DefaultConfig is used.

Types

type Config

type Config struct {
	// StackSize is the maximum size of the stack trace buffer in bytes.
	// Default: 4096.
	StackSize int

	// DisableStackAll disables capturing the stack of all goroutines.
	// When false (default), runtime.Stack is called with all=true.
	DisableStackAll bool

	// DisablePrintStack disables logging the stack trace.
	// When true, the panic value is still logged but the stack trace is omitted.
	DisablePrintStack bool
}

Config holds configuration for the recovery middleware.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default recovery configuration.

Jump to

Keyboard shortcuts

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