httpclient

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package httpclient provides a low-level HTTP client with configurable retry behaviour. It is the transport layer beneath internal/api and has no knowledge of Aura-specific concepts such as base URLs, API versions, or authentication.

Index

Constants

View Source
const (
	// DefaultMaxResponseSize is the maximum size of response body to read (10MB).
	DefaultMaxResponseSize = 10 * 1024 * 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPResponse

type HTTPResponse struct {
	StatusCode int
	Body       []byte
	Headers    http.Header
}

HTTPResponse stores the response from a request, including the payload and headers.

type HTTPService

type HTTPService interface {
	Get(ctx context.Context, url string, headers map[string]string) (*HTTPResponse, error)
	Post(ctx context.Context, url string, headers map[string]string, body string) (*HTTPResponse, error)
	Put(ctx context.Context, url string, headers map[string]string, body string) (*HTTPResponse, error)
	Patch(ctx context.Context, url string, headers map[string]string, body string) (*HTTPResponse, error)
	Delete(ctx context.Context, url string, headers map[string]string) (*HTTPResponse, error)
}

HTTPService defines the interface for HTTP operations. This is the low-level HTTP layer that handles raw HTTP requests.

func NewHTTPService

func NewHTTPService(timeout time.Duration, maxRetry int, logger *slog.Logger) HTTPService

NewHTTPService creates a new HTTPService backed by a retryable HTTP client. Retries are attempted only on network-level errors (no response received); HTTP error responses (including 5xx) are always returned to the caller. The caller-supplied logger is used for debug output.

Jump to

Keyboard shortcuts

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