From a4554be33914fd7cd77eea3326a747078bbe4c50 Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Sun, 24 Jan 2021 10:31:53 -0500 Subject: initial --- http.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 http.go (limited to 'http.go') 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 +} -- cgit v1.2.3