[WIP] add initial support for acceptable status code ranges
This adds an extra, optional, json config branch for specifying an acceptable status code range. (keeping in spirit of cohesive json/go).
The new schema follows
{
"type": "http",
"endpoint_name": "Site Dot Com",
"endpoint_url": "https://site.com",
"up_status_range": {
"min": 200,
"max": 399
}
}
If one - but not both - of the values are present, it's taken to mean "anything above x" or "anything below x" (respectively).
If neither, or nil vals, are provided, this branch doesn't execute. (The eval is min > 0 || max < 999)
In the control flow of (http) *Checker.checkDown(), this is evaluated before the current (upstream/master) map of acceptables.
It returns nil, escaping before that flow.
This is to address #142
TODO: Update tests to allow new struct fields (sorry! if I include [ci skip] in commit msgs, will travis wait?)
TODO: By escaping this early in the check method, we preclude checking resp.body also. It's very reasonable that a user would want to check resp.statuscode between 200, 400 and resp.body contains "welcome".
This is an easy fix by adding respCodeValid bool near the top, and escaping either resp code test if true, then continuing on to resp.body if defined.
(TBD: I don't like temporary mallocs in go)