uri

package
v0.0.0-...-8223eb1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var URICopy = DefaultFetcher.CopyLocal

URICopy Wraps opening and copying content from URIs. Will attempt directly perform file copies if the uri is begins with file://, otherwise delegates to a curl implementation.

Functions

This section is empty.

Types

type BasicFetcher

type BasicFetcher struct {
	Client *http.Client
}

BasicFetcher can access "file" and "http" schemes using the OS and a provided HTTP client, respectively.

func (BasicFetcher) CopyLocal

func (f BasicFetcher) CopyLocal(srcUri *url.URL, dstPath string) (err error)

func (BasicFetcher) Head

func (f BasicFetcher) Head(u *url.URL) (*http.Response, error)

func (BasicFetcher) Open

func (f BasicFetcher) Open(u *url.URL) (io.ReadCloser, error)

type Fetcher

type Fetcher interface {
	// Opens a data stream to the source URI. If no URI scheme is
	// specified, treats the URI as a path to a local file.
	Open(uri *url.URL) (io.ReadCloser, error)

	Head(uri *url.URL) (*http.Response, error)

	// Copy all data from the source URI to a local file at the
	// destination path.
	CopyLocal(srcUri *url.URL, dstPath string) error
}

A UriFetcher presents simple methods for fetching URIs from different schemes.

var DefaultFetcher Fetcher = BasicFetcher{http.DefaultClient}

A default fetcher, if the user doesn't want to set any options.

type LoggedFetcher

type LoggedFetcher struct {
	SrcUri  *url.URL
	DstPath string
	// contains filtered or unexported fields
}

A LoggedFetcher wraps another uri.Fetcher, forwarding all calls and recording their arguments. Useful for unit testing.

func NewLoggedFetcher

func NewLoggedFetcher(fetcher Fetcher) *LoggedFetcher

func (*LoggedFetcher) CopyLocal

func (f *LoggedFetcher) CopyLocal(srcUri *url.URL, dstPath string) error

func (*LoggedFetcher) Head

func (f *LoggedFetcher) Head(srcUri *url.URL) (*http.Response, error)

func (*LoggedFetcher) Open

func (f *LoggedFetcher) Open(srcUri *url.URL) (io.ReadCloser, error)

Jump to

Keyboard shortcuts

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