loader

package
v0.0.0-...-b9ceb1f Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2018 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Content

type Content struct {
	Path            string
	Hash            string
	Modified        time.Time
	Raw             string
	Compressed      string
	RawBytes        []byte
	CompressedBytes []byte
}

Content represents a single embedded file.

func (Content) IsDir

func (f Content) IsDir() bool

func (Content) ModTime

func (f Content) ModTime() time.Time

func (Content) Mode

func (f Content) Mode() os.FileMode

func (Content) Name

func (f Content) Name() string

func (Content) Size

func (f Content) Size() int64

func (Content) Sys

func (f Content) Sys() interface{}

type DiskLoader

type DiskLoader struct {
	Root string
	http.Handler
}

func NewOnDisk

func NewOnDisk(root string) *DiskLoader

NewOnDisk creates a new Loader that loads content from disk.

func (*DiskLoader) GetContents

func (l *DiskLoader) GetContents(path string) ([]byte, error)

type EmbeddedLoader

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

func New

func New() *EmbeddedLoader

NewOnDisk creates a new Loader that loads embedded content.

func (*EmbeddedLoader) Add

func (l *EmbeddedLoader) Add(c *Content)

Add an embedded file to the Loader.

func (*EmbeddedLoader) GetContents

func (l *EmbeddedLoader) GetContents(path string) ([]byte, error)

func (*EmbeddedLoader) Open

func (l *EmbeddedLoader) Open(name string) (http.File, error)

Open implements http.FileSystem

func (*EmbeddedLoader) ServeHTTP

func (l *EmbeddedLoader) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Loader

type Loader interface {
	http.Handler

	// GetContents returns the contents of the file at path, or
	// os.ErrNoExist if no such file is found.
	GetContents(path string) ([]byte, error)
}

Loader types expose content which may be embedded in a binary or loaded from disk at runtime.

Jump to

Keyboard shortcuts

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