Documentation
¶
Index ¶
- Variables
- func BuildUserAgent(version string) string
- func SetMaxResponseSizeForTest(n int64) (restore func())
- func SetUserAgent(ua string)
- type Client
- func (c *Client) DoJSON(method, path string, reqBody, respBody interface{}) error
- func (c *Client) Get(path string, respBody interface{}) error
- func (c *Client) GetRawToWriter(path string, w io.Writer) error
- func (c *Client) Patch(path string, reqBody, respBody interface{}) error
- func (c *Client) Post(path string, reqBody, respBody interface{}) error
Constants ¶
This section is empty.
Variables ¶
var ErrConflict = errors.New("conflict")
ErrConflict is returned when the server returns 409. This typically means the resource already exists (e.g., duplicate link).
var ErrSessionNotFound = errors.New("session not found")
ErrSessionNotFound is returned when the server returns 404. This typically means the session was deleted from the backend.
ErrUnauthorized is returned when the server returns 401 or 403. This typically means the API key is invalid or expired.
Functions ¶
func BuildUserAgent ¶
BuildUserAgent constructs a User-Agent string in the format: confab/version (os; arch)
func SetMaxResponseSizeForTest ¶ added in v0.16.0
func SetMaxResponseSizeForTest(n int64) (restore func())
SetMaxResponseSizeForTest temporarily lowers the response-size cap so tests can exercise the limit without allocating 32MB of memory. Returns a restore function that callers should defer. Intended for test code only — do not call from production.
func SetUserAgent ¶
func SetUserAgent(ua string)
SetUserAgent sets the User-Agent header for all HTTP requests. Should be called once at startup before any requests are made.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a configured HTTP client for making authenticated requests to the backend
func (*Client) DoJSON ¶
DoJSON performs an HTTP request with JSON body and parses JSON response Automatically sets Content-Type, Authorization, and handles error responses. Payloads larger than 1KB are compressed with zstd. Retries with exponential backoff on 429 (rate limited) responses.
func (*Client) GetRawToWriter ¶ added in v0.15.0
GetRawToWriter performs a GET request and streams the response body to w. Unlike Get/DoJSON, this does not attempt JSON unmarshaling — it copies the raw response bytes directly. Handles auth and error status mapping, but does not retry on 429 (retrying a stream would produce corrupt output since partial data from the first attempt is already written to w).