(ctx *context, req *http.Request)
| 1235 | } |
| 1236 | |
| 1237 | func (p *Proxy) rejectBackend(ctx *context, req *http.Request) (*http.Response, bool) { |
| 1238 | limit, ok := ctx.StateBag()[filters.BackendRatelimit].(*ratelimitfilters.BackendRatelimit) |
| 1239 | if ok { |
| 1240 | s := req.URL.Scheme + "://" + req.URL.Host |
| 1241 | |
| 1242 | if !p.limiters.Get(limit.Settings).Allow(req.Context(), s) { |
| 1243 | return &http.Response{ |
| 1244 | StatusCode: limit.StatusCode, |
| 1245 | Header: http.Header{"Content-Length": []string{"0"}}, |
| 1246 | Body: io.NopCloser(&bytes.Buffer{}), |
| 1247 | }, true |
| 1248 | } |
| 1249 | } |
| 1250 | return nil, false |
| 1251 | } |
| 1252 | |
| 1253 | func (p *Proxy) checkBreaker(c *context) (func(bool), bool) { |
| 1254 | if p.breakers == nil { |
no test coverage detected