resource

package
Version: v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: MIT Imports: 9 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists(i Instance) bool

func Move

func Move(from, to Instance) (err error)

Move instance content, deleting the source if it succeeds.

func ReadSeeker

func ReadSeeker(r Instance) io.ReadSeeker

Creates a io.ReadSeeker to an Instance.

Types

type HTTPProvider

type HTTPProvider struct {
	Client *http.Client
}

Provides access to resources through a http.Client.

func (*HTTPProvider) NewInstance

func (me *HTTPProvider) NewInstance(urlStr string) (r Instance, err error)

type Instance

type Instance interface {
	Get() (io.ReadCloser, error)
	Put(io.Reader) error
	Stat() (os.FileInfo, error)
	ReadAt([]byte, int64) (int, error)
	WriteAt([]byte, int64) (int, error)
	Delete() error
}

An Instance represents the content at some location accessed through some Provider. It's the data at some URL.

type OSFileProvider

type OSFileProvider struct{}

Provides access to resources through the native OS filesystem.

func (OSFileProvider) NewInstance

func (me OSFileProvider) NewInstance(filePath string) (r Instance, err error)

type Provider

type Provider interface {
	NewInstance(string) (Instance, error)
}

type TranslatedProvider

type TranslatedProvider struct {
	// The underlying Provider.
	BaseProvider Provider
	// Some location used in calculating final locations.
	BaseLocation string
	// Function that takes BaseLocation, and the caller location and returns
	// the location to be used with the BaseProvider.
	JoinLocations func(base, rel string) string
}

TranslatedProvider manipulates resource locations, so as to allow sandboxing, or relative paths for example.

func (TranslatedProvider) NewInstance

func (me TranslatedProvider) NewInstance(rel string) (Instance, error)

Jump to

Keyboard shortcuts

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