Add recover middleware to gracefully handle handler panics

This commit is contained in:
Ioannis Dressos 2026-07-08 12:14:55 +03:00
parent d9fdd3a017
commit dfa2ac5e9f
No known key found for this signature in database
1 changed files with 4 additions and 0 deletions

View File

@ -51,6 +51,10 @@ func (t *TemplateRegistry) Render(w io.Writer, name string, data interface{}, c
func New(tmplDir fs.FS, extraData map[string]interface{}, secret [64]byte) *echo.Echo {
e := echo.New()
// Recover from panics in any middleware or handler so a single bad request
// cannot take down the connection with an unhandled stack trace.
e.Use(middleware.Recover())
cookiePath := util.GetCookiePath()
cookieStore := sessions.NewCookieStore(secret[:32], secret[32:])