checkDown checks whether the endpoint is down based on resp and the configuration of c. It returns a non-nil error if down. Note that it does not check for degraded response.
(body string)
| 169 | // the configuration of c. It returns a non-nil error if down. |
| 170 | // Note that it does not check for degraded response. |
| 171 | func (c Checker) checkDown(body string) error { |
| 172 | // Check response body |
| 173 | if c.MustContain == "" && c.MustNotContain == "" { |
| 174 | return nil |
| 175 | } |
| 176 | if c.MustContain != "" && !strings.Contains(body, c.MustContain) { |
| 177 | return fmt.Errorf("response does not contain '%s'", c.MustContain) |
| 178 | } |
| 179 | if c.MustNotContain != "" && strings.Contains(body, c.MustNotContain) { |
| 180 | return fmt.Errorf("response contains '%s'", c.MustNotContain) |
| 181 | } |
| 182 | return nil |
| 183 | } |