content

package
v0.1.75 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: Apache-2.0 Imports: 14 Imported by: 16

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

View Source
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

func FromURL(ctx context.Context, u *url.URL) (Provider, error)

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.

Jump to

Keyboard shortcuts

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