httpclient

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 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 DefaultClient

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

DefaultClient is the default HTTP client implementation

func (*DefaultClient) Get

func (c *DefaultClient) Get(ctx context.Context, url string) ([]byte, error)

Get performs an HTTP GET request

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