Documentation
¶
Overview ¶
Package recover provides panic recovery utilities for HTTP handlers.
Contract:
- if the response is still uncommitted, a recovered panic becomes a 500 Problem Details response
- if headers or body bytes have already been committed, the middleware logs the panic and aborts the request instead of preserving a misleading partial success response
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
Middleware converts panics into RFC 9457 problem details responses when the response is still uncommitted. If the handler already committed headers or body bytes, the middleware logs the panic and aborts the request rather than preserving a misleading partial success response.
Types ¶
type Option ¶ added in v2.1.0
type Option func(*config)
Option customizes panic recovery logging.
func WithLogger ¶ added in v2.1.0
WithLogger routes panic logs to the provided logger.
func WithStackLogging ¶ added in v2.1.0
WithStackLogging controls whether panic stacks are added to logs.
Click to show internal directories.
Click to hide internal directories.