feat: panic recovering on requests

This commit is contained in:
Guz
2025-03-05 12:22:38 -03:00
parent 4875f47f94
commit 7b6796e2c1

View File

@@ -21,6 +21,7 @@ func New(assertions tinyssert.Assertions, log *slog.Logger, dev bool) http.Handl
} else {
r.Use(middleware.PersistentCache())
}
r.Use(exceptions.PanicMiddleware())
r.Use(exceptions.Middleware())
r.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) {
@@ -32,6 +33,9 @@ func New(assertions tinyssert.Assertions, log *slog.Logger, dev bool) http.Handl
exceptions.WithData("test-data", "test-value"),
).ServeHTTP(w, r)
})
r.HandleFunc("/panic", func(w http.ResponseWriter, r *http.Request) {
panic("TEST PANIC")
})
return r
}