Skip to content

Conversation

@davidspiess
Copy link
Member

Introduces a recoverer middleware that handles panics and delegates error response handling to the caller.

Two tests are included: one with a plain text error response and another with a structured JSON response.
It should also work with a dedicated library like ory/herodot.

@davidspiess davidspiess changed the title feat: add recoverer middleware feat: recoverer middleware Feb 19, 2025
Copy link
Member

@francesconi francesconi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't unit test different error handlers but instead ensure that http.ErrAbortHandler is not recovered. Also, do we want to add a default error handler, or should we enforce that the user always sets one?

@davidspiess davidspiess requested review from francesconi and removed request for TomOne February 20, 2025 19:54
Copy link
Member

@francesconi francesconi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@davidspiess davidspiess merged commit 1b82328 into main Feb 21, 2025
1 check passed
@davidspiess davidspiess deleted the recoverer-middleware branch February 21, 2025 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants