aboutsummaryrefslogtreecommitdiff
path: root/backend/logger.go
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2025-12-26 23:15:06 +0100
committerAnhgelus Morhtuuzh <william@herges.fr>2025-12-26 23:15:06 +0100
commit563494cb7779a840bd650f0cf215b6e6ae7080ed (patch)
tree8a2630444cbfbbe6db9c073450467eeb01e028cd /backend/logger.go
parentaf11793ca48244eafd7dcdf66ac1dff83995a775 (diff)
feat(backend): introduce rate limit to protect auth
Diffstat (limited to 'backend/logger.go')
-rw-r--r--backend/logger.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/backend/logger.go b/backend/logger.go
index da5fadb..f3dbc3c 100644
--- a/backend/logger.go
+++ b/backend/logger.go
@@ -24,10 +24,11 @@ type customWriter struct {
}
func (c *customWriter) WriteHeader(statusCode int) {
- c.statusCode = statusCode
- if statusCode != c.statusCode {
- c.ResponseWriter.WriteHeader(statusCode)
+ if statusCode == c.statusCode {
+ return
}
+ c.statusCode = statusCode
+ c.ResponseWriter.WriteHeader(statusCode)
}
func GetStatusCode(ctx context.Context) func() int {
@@ -58,7 +59,7 @@ func SetLogger(l *slog.Logger) func(http.Handler) http.Handler {
next.ServeHTTP(ww, r.WithContext(ctx))
- if ww.statusCode == http.StatusNotFound {
+ if ww.statusCode == http.StatusNotFound || ww.statusCode == http.StatusTooManyRequests {
return
}
var lvl slog.Level