Blob
1 package icinga3 import (4 "fmt"5 "net/http"6 )8 type Client struct {9 host string10 username string11 password string12 *http.Client13 }15 func Dial(host, username, password string, client *http.Client) (*Client, error) {16 c := &Client{host, username, password, client}17 if _, err := c.Status(); err != nil {18 return nil, err19 }20 return c, nil21 }23 func (c *Client) Status() (*http.Response, error) {24 resp, err := c.get("/status")25 if err != nil {26 return nil, err27 }28 if resp.StatusCode != http.StatusOK {29 return resp, fmt.Errorf("status %s", resp.Status)30 }31 return resp, nil32 }
