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:
parent
4ab450309f
commit
29340e7e24
5 changed files with 89 additions and 45 deletions
server
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue