aboutsummaryrefslogtreecommitdiff
path: root/http.go
blob: f3a910ffc0d098f980d004612ec163f2a7a21eab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
}