http

package
v0.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConflict = errors.New("conflict")

ErrConflict is returned when the server returns 409. This typically means the resource already exists (e.g., duplicate link).

View Source
var ErrRateLimited = errors.New("rate limited")

ErrRateLimited is returned when retries are exhausted on 429 responses.

View Source
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.

View Source
var ErrUnauthorized = errors.New("unauthorized")

ErrUnauthorized is returned when the server returns 401 or 403. This typically means the API key is invalid or expired.

Functions

func BuildUserAgent

func BuildUserAgent(version string) string

BuildUserAgent constructs a User-Agent string in the format: confab/version (os; arch)

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 NewClient

func NewClient(cfg *config.UploadConfig, timeout time.Duration) (*Client, error)

NewClient creates a new authenticated HTTP client

func (*Client) DoJSON

func (c *Client) DoJSON(method, path string, reqBody, respBody interface{}) error

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) Get

func (c *Client) Get(path string, respBody interface{}) error

Get performs a GET request with JSON response parsing

func (*Client) Patch

func (c *Client) Patch(path string, reqBody, respBody interface{}) error

Patch performs a PATCH request with JSON body and response

func (*Client) Post

func (c *Client) Post(path string, reqBody, respBody interface{}) error

Post performs a POST request with JSON body and response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL