fetchurl

package module
v0.0.0-...-f53e655 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 11 Imported by: 0

README

fetchurl

Simple caching server for URLs with a hash.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupportedAlgorithm is returned when the requested hash algorithm is not supported.
	ErrUnsupportedAlgorithm = errors.New("unsupported algorithm")

	// ErrHashMismatch is returned when the downloaded content does not match the expected hash.
	ErrHashMismatch = errors.New("hash mismatch")

	// ErrPartialWrite is returned when data was already written to Out before a failure occurred,
	// making fallback to another source unsafe.
	ErrPartialWrite = errors.New("partial write")

	// ErrAllSourcesFailed is returned when no server or direct source could provide the content.
	ErrAllSourcesFailed = errors.New("all sources failed")
)

Functions

This section is empty.

Types

type FetchOptions

type FetchOptions struct {
	Algo string
	Hash string
	URLs []string
	Out  io.Writer
}

type Fetcher

type Fetcher struct {
	Client  *http.Client
	Servers []string
}

func NewFetcher

func NewFetcher(client *http.Client) *Fetcher

func (*Fetcher) Fetch

func (f *Fetcher) Fetch(ctx context.Context, opts FetchOptions) error

type HTTPStatusError

type HTTPStatusError struct {
	StatusCode int
}

HTTPStatusError is returned when a source responds with a non-200 status code.

func (*HTTPStatusError) Error

func (e *HTTPStatusError) Error() string

Jump to

Keyboard shortcuts

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