IsPingable calls the API /ping to determine whether the API can be reached.
()
| 92 | |
| 93 | // IsPingable calls the API /ping to determine whether the API can be reached. |
| 94 | func (c *Client) IsPingable() error { |
| 95 | url := fmt.Sprintf("%s/ping", c.APIBaseURL) |
| 96 | req, err := c.NewRequest("GET", url, nil) |
| 97 | if err != nil { |
| 98 | return err |
| 99 | } |
| 100 | resp, err := c.Do(req) |
| 101 | if err != nil { |
| 102 | return err |
| 103 | } |
| 104 | defer resp.Body.Close() |
| 105 | |
| 106 | if resp.StatusCode != http.StatusOK { |
| 107 | return fmt.Errorf("API returned %s", resp.Status) |
| 108 | } |
| 109 | return nil |
| 110 | } |
no test coverage detected