diff options
Diffstat (limited to 'http.go')
| -rw-r--r-- | http.go | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -1,14 +1,13 @@ package checkup import ( + "errors" "fmt" "net/http" "time" ) -func HttpStatusOK(url string, timeout, status int) error { - client := &http.Client{Timeout: time.Duration(timeout) * time.Second} - +func httpReq(client *http.Client, url string, timeout, status int) error { resp, err := client.Get(url) if err != nil { @@ -24,3 +23,20 @@ func HttpStatusOK(url string, timeout, status int) error { return nil } + +func HttpStatusOK(url string, timeout, status int) error { + client := &http.Client{Timeout: time.Duration(timeout) * time.Second} + return httpReq(client, url, timeout, status) +} + +func HttpNoRedirectStatusOK(url string, timeout, status int) error { + client := &http.Client{ + Timeout: time.Duration(timeout) * time.Second, + CheckRedirect: httpNoRedirectfunc, + } + return httpReq(client, url, timeout, status) +} + +func httpNoRedirectfunc(req *http.Request, via []*http.Request) error { + return errors.New("Redirected") +} |
