Help us shape the future of Go! Take the 2026 Go Developer Survey

httpclient

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package httpclient provides HTTP client functionality for API operations

Index

Constants

View Source
const (
	// DefaultTimeout is the default timeout for HTTP requests
	DefaultTimeout = 10 * time.Second

	// MaxResponseSize is the maximum allowed response size (100MB)
	MaxResponseSize = 100 * 1024 * 1024

	// UserAgent is the user agent string for HTTP requests
	UserAgent = "toolhive-registry-server/1.0"
)

Variables

This section is empty.

Functions

func NewHTTPError

func NewHTTPError(statusCode int, url, message string) error

NewHTTPError creates a new HTTP error

Types

type Client

type Client interface {
	// Get performs an HTTP GET request and returns the response body
	Get(ctx context.Context, url string) ([]byte, error)
}

Client is an interface for HTTP operations

func NewDefaultClient

func NewDefaultClient(timeout time.Duration) Client

NewDefaultClient creates a new default HTTP client with the specified timeout If timeout is 0, uses DefaultTimeout

type HTTPError

type HTTPError struct {
	StatusCode int
	Message    string
	URL        string
}

HTTPError represents an HTTP error

func (*HTTPError) Error

func (e *HTTPError) Error() string

Error returns the error message

Jump to

Keyboard shortcuts

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