- Replaced http.Error with helpers.RenderError in Recover middleware - Custom 500.html now rendered with layout and topbar on panic - RenderError gracefully checks template existence and falls back to plain response - Added /account/notifications full view page (index) - Linked "Back to notifications" from notification read view - Fixed typo in template path for notifications/index.html - Improved layout consistency across error and account pages
23 lines
496 B
Go
23 lines
496 B
Go
package middleware
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
"runtime/debug"
|
|
"synlotto-website/helpers"
|
|
)
|
|
|
|
func Recover(next http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
defer func() {
|
|
if rec := recover(); rec != nil {
|
|
log.Printf("🔥 Recovered from panic: %v\n%s", rec, debug.Stack())
|
|
|
|
// ✅ Call your custom template-based fallback
|
|
helpers.RenderError(w, r, http.StatusInternalServerError)
|
|
}
|
|
}()
|
|
next.ServeHTTP(w, r)
|
|
})
|
|
}
|