aboutsummaryrefslogtreecommitdiff
path: root/http.go
diff options
context:
space:
mode:
Diffstat (limited to 'http.go')
-rw-r--r--http.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/http.go b/http.go
new file mode 100644
index 0000000..f3a910f
--- /dev/null
+++ b/http.go
@@ -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
+}