Return every error as {"error": "..."}

Echo errors, middleware and handlers used three different formats (message object, error object, bare string). One error handler now writes all of them the same way; status codes are unchanged.
This commit is contained in:
Sansan committed 2026-10-06 16:21:14 +02:00
1 parent bc7d406e41
commit 0ec2425f78
9 files changed
+67 -21

No files matched your search

+1 -3
View File
@@ -23,9 +23,7 @@ func RateLimit(limit int, window time.Duration) echo.MiddlewareFunc {
logging.GetLogger().Warn("Rate limit exceeded",
zap.String("ip", identifier),
zap.String("path", c.Request().URL.Path))
return c.JSON(http.StatusTooManyRequests, map[string]string{
"error": "Rate limit exceeded. Please try again later.",
})
return echo.NewHTTPError(http.StatusTooManyRequests, "Rate limit exceeded. Please try again later.")
}
return echoMiddleware.RateLimiterWithConfig(config)
}