aboutsummaryrefslogtreecommitdiff
path: root/http.go
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2021-01-24 10:31:53 -0500
committerMitch Riedstra <mitch@riedstra.us>2021-01-24 10:31:53 -0500
commita4554be33914fd7cd77eea3326a747078bbe4c50 (patch)
tree5e97506f384344662f9d3e55a6f83f88c76d6217 /http.go
downloadcheckup-a4554be33914fd7cd77eea3326a747078bbe4c50.tar.gz
checkup-a4554be33914fd7cd77eea3326a747078bbe4c50.tar.xz
initial
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
+}