Documentation
¶
Overview ¶
Package api is the HTTP client for the Checkend API. It maps HTTP errors to exit codes.
Index ¶
- func OrNotFound(raw json.RawMessage, err error, msg, hint string) (json.RawMessage, error)
- type Client
- func (c *Client) Call(method, path string, body []byte, contentType string) (json.RawMessage, error)
- func (c *Client) Delete(path string) (json.RawMessage, error)
- func (c *Client) Get(path string, query map[string]string) (json.RawMessage, error)
- func (c *Client) Health() (Health, json.RawMessage, error)
- func (c *Client) Post(path string, body any) (json.RawMessage, error)
- func (c *Client) PostRaw(path string, body []byte, accept string) (int, string, []byte, error)
- func (c *Client) Text(path string) (string, error)
- type Health
- type NotFound
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OrNotFound ¶
func OrNotFound(raw json.RawMessage, err error, msg, hint string) (json.RawMessage, error)
OrNotFound replaces a 404 with the given message and hint.
Types ¶
type Client ¶
type Client struct {
URL string
// contains filtered or unexported fields
}
Client calls one Checkend instance.
func (*Client) Call ¶
func (c *Client) Call(method, path string, body []byte, contentType string) (json.RawMessage, error)
Call sends a request with the token and returns the JSON body of a 2xx response.
func (*Client) Delete ¶
func (c *Client) Delete(path string) (json.RawMessage, error)
Delete calls DELETE path.
func (*Client) Health ¶
func (c *Client) Health() (Health, json.RawMessage, error)
Health calls GET /health. It needs no token. A 503 still has a health body.
type Health ¶
type Health struct {
Status string `json:"status"`
Version any `json:"version"`
Ingest *struct {
Mode any `json:"mode"`
} `json:"ingest"`
}
Health is the body of GET /health.