provider

package
v1.4.23 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when the file could not be found on the provider.
	ErrNotFound = errors.New("not found")

	// ErrFilename is returned when the filename could not be parsed by the
	// provider.
	ErrFilename = errors.New("bad filename")

	// ErrBadGateway is returned when the upstream provider could not service the
	// request.
	ErrBadGateway = errors.New("bad gateway")
)

Functions

func NewGCSTransport

func NewGCSTransport(ctx context.Context) (http.RoundTripper, error)

NewGCSTransport returns the transport used by GCS.

Types

type Filesystem

type Filesystem struct {
	Dir http.Dir
}

Filesystem provides a way to load files from the filesystem.

func (*Filesystem) Provide

func (fp *Filesystem) Provide(ctx context.Context, filename string) (io.ReadCloser, error)

Provide provides a file via the virtual http.Dir filesystem.

type GCS

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

GCS provides a way to access files from Google Cloud Storage. Credentials used are loaded from the `GOOGLE_APPLICATION_CREDENTIALS` environment variable.

func NewGCS

func NewGCS(ctx context.Context, bucket string, transport http.RoundTripper) (*GCS, error)

NewGCS will create the GCS Provider.

func (*GCS) Provide

func (gcs *GCS) Provide(ctx context.Context, filename string) (io.ReadCloser, error)

Provide provides a file by making a request to Google Cloud Storage with the specified key and then returning the response body when the request was complete.

type Origin

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

Origin provides a way to access files from a url.

func NewOrigin

func NewOrigin(baseURL *url.URL, transport http.RoundTripper) *Origin

NewOrigin returns a new Origin Provider that will return files relative to the provided base url.

func (*Origin) Provide

func (op *Origin) Provide(ctx context.Context, filename string) (io.ReadCloser, error)

Provide provides a file by making a request to the origin server with the specified filename and then returning the response body when the request was complete.

type Provider

type Provider interface {
	Provide(ctx context.Context, filename string) (io.ReadCloser, error)
}

Provider describes a struct that provides the "Provide" method to provide an image from a filename.

type Proxy added in v1.3.7

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

Proxy provides a way to access files from a url.

func NewProxy added in v1.3.7

func NewProxy(transport http.RoundTripper) *Proxy

NewProxy returns a new Proxy Provider that will return files.

func (*Proxy) Handle added in v1.3.7

func (pp *Proxy) Handle(ctx context.Context, fileURL fmt.Stringer) (io.ReadCloser, error)

Handle implements the reusable logic behind the Proxy Provider.

func (*Proxy) Provide added in v1.3.7

func (pp *Proxy) Provide(ctx context.Context, filename string) (io.ReadCloser, error)

Provide provides a file by making a request to the server with the specified filename and then returning the response body when the request was complete.

type S3

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

S3 is a file provider that is capable of providing files from any S3 compatible service such as Minio or Amazon S3 itself.

func NewS3

func NewS3(bucket string, transport http.RoundTripper) (*S3, error)

NewS3 returns an S3 client capable of providing files from any S3 compatible service such as Minio or Amazon S3 itself.

func (*S3) Provide

func (s *S3) Provide(ctx context.Context, filename string) (io.ReadCloser, error)

Provide loads the file from the S3 client.

Jump to

Keyboard shortcuts

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