diff options
| author | Mitch Riedstra <mitch@riedstra.us> | 2021-01-24 10:31:53 -0500 |
|---|---|---|
| committer | Mitch Riedstra <mitch@riedstra.us> | 2021-01-24 10:31:53 -0500 |
| commit | a4554be33914fd7cd77eea3326a747078bbe4c50 (patch) | |
| tree | 5e97506f384344662f9d3e55a6f83f88c76d6217 /http.go | |
| download | checkup-a4554be33914fd7cd77eea3326a747078bbe4c50.tar.gz checkup-a4554be33914fd7cd77eea3326a747078bbe4c50.tar.xz | |
initial
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 +} |
