Documentation
¶
Overview ¶
Package cfapi is the shared transport for every Cloudflare v4 API call mailctl makes: DNS, Email Routing, Email Sending, and Workers.
Index ¶
- func List[T any](ctx context.Context, c *Client, path string) ([]T, error)
- type Client
- func (c *Client) Do(ctx context.Context, method, path string, body, result any) error
- func (c *Client) Multipart(ctx context.Context, method, path string, parts []Part, result any) error
- func (c *Client) Raw(ctx context.Context, path string) (body []byte, contentType string, found bool, err error)
- func (c *Client) String() string
- type Part
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func List ¶
List fetches every page of a paginated collection endpoint. path may already carry a query string; page and per_page are appended to it.
If pagination does not terminate within maxListPages, List returns an error. We return an error rather than silently truncating because a partial result would cause the diff engine to think records were deleted when we merely failed to fetch all pages.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Do ¶
Do performs one request. body is JSON-marshalled when non-nil; result is JSON-unmarshalled from the envelope's result field when non-nil.
func (*Client) Multipart ¶
func (c *Client) Multipart(ctx context.Context, method, path string, parts []Part, result any) error
Multipart performs a multipart/form-data request.
func (*Client) Raw ¶
func (c *Client) Raw(ctx context.Context, path string) (body []byte, contentType string, found bool, err error)
Raw performs a GET and returns the response body unparsed, for endpoints that answer with something other than the JSON envelope. found is false when the resource does not exist, which is a normal state rather than an error. contentType is the response's Content-Type header, since some of those endpoints answer with a shape (e.g. multipart/form-data) that callers must detect before they can parse the body.