Skip to content

Use gorilla/mux middleware to recover panics #313

@johnabass

Description

@johnabass

Currently, any panic from HTTP handlers can cause the http.Server to stop processing requests. We can prevent this by adding a middleware to the *mux.Router that recovers any panic, logs it, and then returns a configurable status code. This will prevent issues like invalid UTF-8 from causing caduceus to stop accepting requests.

The recovery handler itself should probably go into github.com/xmidt-org/httpaux.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions