Documentation ¶
Overview ¶
Package content provides a unified way of turning a URL into a struct that provides an array of bytes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnsupportedURLScheme = errors.New("Unsupported URL scheme") ErrNoChange = errors.New("Data is unchanged") )
Errors that might be returned outside the package.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider interface { // Get returns the raw file []byte read from the latest copy of the provider // URL. It may be called multiple times. Caching is left up to the individual // Provider implementation. Get(ctx context.Context) ([]byte, error) }
Provider is the interface implemented by everything that can return raw files.
func FromURL ¶
FromURL returns a new rawfile.Provider based on the passed-in URL. Supported URL schemes are currently: gs://bucket/filename, file:localpath, and https://. Whether the path contained in the URL is valid isn't known until the Get() method of the returned Provider is called. Unsupported URL schemes cause this to return ErrUnsupportedURLScheme.
Users interested in having the daemon download the data directly from MaxMind using credentials should implement an alternate https case in the below handler. M-Lab doesn't need that case because we cache MaxMind's data to reduce load on their servers and to eliminate a runtime dependency on a third party service.