fetcher

package
v0.0.631 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 15 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownScheme = stderrors.New("unknown scheme")

Functions

This section is empty.

Types

type Fetcher

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

Fetcher is able to load file contents from http, https, file, and base64 locations.

func NewFetcher

func NewFetcher(opts ...Modifier) *Fetcher

NewFetcher creates a new fetcher instance.

func (*Fetcher) Fetch

func (f *Fetcher) Fetch(source string) (*bytes.Buffer, error)

Fetch fetches the file contents from the source.

func (*Fetcher) FetchBytes added in v0.0.613

func (f *Fetcher) FetchBytes(ctx context.Context, source string) ([]byte, error)

FetchBytes fetches the file contents from the source and allows to pass a context that is used for HTTP requests.

func (*Fetcher) FetchContext added in v0.0.542

func (f *Fetcher) FetchContext(ctx context.Context, source string) (*bytes.Buffer, error)

FetchContext fetches the file contents from the source and allows to pass a context that is used for HTTP requests.

type Modifier added in v0.0.586

type Modifier func(*opts)

func WithCache added in v0.0.610

func WithCache(cache *ristretto.Cache, ttl time.Duration) Modifier

func WithClient

func WithClient(hc *retryablehttp.Client) Modifier

WithClient sets the http.Client the fetcher uses.

func WithMaxHTTPMaxBytes added in v0.0.601

func WithMaxHTTPMaxBytes(limit int64) Modifier

WithMaxHTTPMaxBytes reads at most limit bytes from the HTTP response body, returning bytes.ErrToLarge if the limit would be exceeded.

Jump to

Keyboard shortcuts

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