diff options
Diffstat (limited to 'http.go')
| -rw-r--r-- | http.go | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -0,0 +1,23 @@ +package checkup + +import ( + "fmt" + "net/http" +) + +func HttpStatusOK(url string, status int) error { + resp, err := http.Get(url) + + if err != nil { + return err + } + + defer resp.Body.Close() + + if resp.StatusCode != status { + return fmt.Errorf("Bad status code, expected %d got: %d", + status, resp.StatusCode) + } + + return nil +} |
