httpx

package
v0.0.0-...-873d3b2 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package httpx centralizes HTTP client behavior such as retries and rate limiting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps HTTP access with Bitbucket-aware defaults.

func New

func New(opts Options) (*Client, error)

New constructs a Client from options.

func (*Client) Do

func (c *Client) Do(req *http.Request, v any) error

Do executes the HTTP request and decodes the response into v when provided.

func (*Client) NewMultipartRequest

func (c *Client) NewMultipartRequest(ctx context.Context, method, path string, files []MultipartFile) (*http.Request, error)

NewMultipartRequest builds a multipart/form-data request for file uploads. The request body is buffered in memory to support retries.

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method, path string, body any) (*http.Request, error)

NewRequest builds an HTTP request relative to the base URL. Body values are JSON encoded when non-nil.

func (*Client) RateLimitState

func (c *Client) RateLimitState() RateLimit

RateLimitState returns the last observed rate limit headers.

type MultipartFile

type MultipartFile struct {
	FieldName string    // Form field name (e.g., "files")
	FileName  string    // Original filename
	Reader    io.Reader // File content
}

MultipartFile represents a file for multipart/form-data upload.

type Options

type Options struct {
	BaseURL   string
	Username  string
	Password  string
	UserAgent string
	Timeout   time.Duration

	EnableCache bool
	Retry       RetryPolicy
	Debug       bool
}

Options configures a Client.

type RateLimit

type RateLimit struct {
	Limit     int
	Remaining int
	Reset     time.Time
	Source    string
}

RateLimit captures headers advertised by Bitbucket for throttling.

type RetryPolicy

type RetryPolicy struct {
	MaxAttempts    int
	InitialBackoff time.Duration
	MaxBackoff     time.Duration
}

RetryPolicy defines exponential backoff characteristics for retries.

Jump to

Keyboard shortcuts

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