Update template

This commit is contained in:
2025-05-24 08:52:11 +02:00
parent ca8b1a2e46
commit 542d28e7a9
18 changed files with 293 additions and 235 deletions

View File

@@ -0,0 +1,18 @@
package middleware
import (
"log/slog"
"net/http"
)
func RecoverMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
defer func() {
if err := recover(); err != nil {
slog.Error("Recovered from panic", "error", err)
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
}
}()
next.ServeHTTP(w, r)
})
}