diff --git a/server/middleware/doc.go b/server/middleware/doc.go index 2a8fd21..7e4bfa1 100644 --- a/server/middleware/doc.go +++ b/server/middleware/doc.go @@ -5,8 +5,8 @@ incoming HTTP requests and produce appropriate responses. The package includes middleware for security headers (SetPrivacyHeaders), error catching and handling (CatchError, HandleError), rate limiting (IPRateLimiter, RateLimitRequest), logging (LogRequest), -panic recovery (RecoverFromPanic), and user context injection (ProvideUserContext). These -middlewares can be applied to routes to add cross-cutting functionality across multiple endpoints. +and user context injection (ProvideUserContext). These middlewares can be applied to routes to add cross-cutting +functionality across multiple endpoints. Route definitions are centralized in the DefineRoutes function, which sets up all paths and their corresponding handlers using the gorilla/mux router. diff --git a/server/middleware/recover.go b/server/middleware/recover.go deleted file mode 100644 index 13e7f88..0000000 --- a/server/middleware/recover.go +++ /dev/null @@ -1,28 +0,0 @@ -package middleware - -import ( - "net/http" -) - -// RecoverFromPanic wraps an http.Handler and recovers from any panics that occur during its execution. -// If a panic occurs, it sends an HTTP 500 Internal Server Error response with the panic message. -func RecoverFromPanic(h http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - var errorString string - defer func() { - r := recover() - if r != nil { - switch t := r.(type) { - case string: - errorString = t - case error: - errorString = t.Error() - default: - errorString = "Unknown error" - } - http.Error(w, errorString, http.StatusInternalServerError) - } - }() - h.ServeHTTP(w, r) - }) -}