1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-05-21 06:18:25 +02:00

Add test, fails

This commit is contained in:
binwiederhier 2023-02-22 21:00:56 -05:00
parent 4ab450309f
commit 29340e7e24
5 changed files with 89 additions and 45 deletions

View file

@ -25,15 +25,15 @@ func (s *Server) limitRequestsWithTopic(next handleFunc) handleFunc {
if err != nil {
return err
}
vRate := v
vrate := v
if topicCountsAgainst := t.Billee(); topicCountsAgainst != nil {
vRate = topicCountsAgainst
vrate = topicCountsAgainst
}
r = r.WithContext(context.WithValue(context.WithValue(r.Context(), "vRate", vRate), "topic", t))
r = r.WithContext(context.WithValue(context.WithValue(r.Context(), "vRate", vrate), "topic", t))
if util.ContainsIP(s.config.VisitorRequestExemptIPAddrs, v.ip) {
return next(w, r, v)
} else if !vRate.RequestAllowed() {
} else if !vrate.RequestAllowed() {
return errHTTPTooManyRequestsLimitRequests
}
return next(w, r, v)