Skip to content

Commit

Permalink
added log
Browse files Browse the repository at this point in the history
  • Loading branch information
igorgoldobin committed Feb 7, 2024
1 parent a5bf5b6 commit 3355a7d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/server/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ func (l *Limiter) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.Ha

func (l *Limiter) limitByKey(w http.ResponseWriter, key string) bool {
if _, ttl, err := l.cache.GetWithTTL(key); err == nil {
errMsg := fmt.Sprintf("You have exceeded the rate limit. Please wait %s before you try again", ttl.Round(time.Second))
errMsg := fmt.Sprintf("You have exceeded the rate limit for %s. Please wait %s before you try again", key, ttl.Round(time.Second))
fmt.Println(errMsg)
renderJSON(w, claimResponse{Message: errMsg}, http.StatusTooManyRequests)
return true
}
Expand Down

0 comments on commit 3355a7d

Please sign in to comment.