Match returns true if code is within any configured range.
(code int)
| 21 | |
| 22 | // Match returns true if code is within any configured range. |
| 23 | func (m StatusCodeMatcher) Match(code int) bool { |
| 24 | if len(m.ranges) == 0 { |
| 25 | return false |
| 26 | } |
| 27 | |
| 28 | // Find first range whose Start is greater than code, then check previous one. |
| 29 | i := sort.Search(len(m.ranges), func(i int) bool { |
| 30 | return m.ranges[i].Start > code |
| 31 | }) |
| 32 | if i == 0 { |
| 33 | return false |
| 34 | } |
| 35 | r := m.ranges[i-1] |
| 36 | return code >= r.Start && code <= r.End |
| 37 | } |
| 38 | |
| 39 | // IsEmpty reports whether the matcher has no ranges configured. |
| 40 | func (m StatusCodeMatcher) IsEmpty() bool { |
no outgoing calls
no test coverage detected