assetmgr

package
v0.0.0-...-8fa2440 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2016 License: MIT Imports: 15 Imported by: 2

Documentation

Overview

Package assetmgr facilitates the automatic generation and live updation of asset cachebusting tags as files are changed.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = fmt.Errorf("static file not found")
View Source
var ErrUnsupportedMethod = fmt.Errorf("unsupported method")
View Source
var _, Log = xlog.New("web.assetmgr")

Functions

This section is empty.

Types

type Config

type Config struct {
	Path string // Path to assets.
}

Asset manager configuration.

type Info

type Info interface {
	// Return asset modification time.
	ModTime() time.Time

	// Return cache invalidating hash tag.
	Tag() string

	// SHA256 hash of data.
	SHA256() []byte

	// Return path to asset.
	FullPath() string
}

Represents an asset.

type Manager

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

Asset manager.

var Default *Manager

func New

func New(cfg Config) (*Manager, error)

Create new asset manager.

func (*Manager) Close

func (m *Manager) Close()

Shut down the asset manager.

func (*Manager) Info

func (m *Manager) Info(path string) Info

Return info for the asset with the given path.

func (*Manager) SHA256

func (m *Manager) SHA256(path string) []byte

Return SHA256 of file data or nil if file not found.

func (*Manager) Tag

func (m *Manager) Tag(path string) string

Return cache invalidating hash tag for the asset with the given path.

func (*Manager) TryHandle

func (m *Manager) TryHandle(rw http.ResponseWriter, req *http.Request) error

Serve static files from assets.

Jump to

Keyboard shortcuts

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