Kern
Middleware guides

Middleware - Recovery

Detailed guide to Kern.Recovery middleware for panic-safe request handling in production Go services.

Kern.Recovery

kern.Recovery catches panics in handlers or middleware and returns 500.

Signature

func Recovery() MiddlewareFunc

Example

app := kern.New()
app.Use(kern.Recovery())

Best practices

  • Always enable in production.
  • Keep it near the outer layer so most downstream panics are captured.