golazy.dev
–
golazy.dev
/
lazyassets
Index
|
Files
package lazyassets
import "golazy.dev/lazyassets"
Types
type Asset
type Asset struct {
Path string `json:"path"`
Permanent string `json:"permanent,omitempty"`
ContentType string `json:"content_type,omitempty"`
Size int64 `json:"size"`
Hash string `json:"hash,omitempty"`
ETag string `json:"etag,omitempty"`
Integrity string `json:"integrity,omitempty"`
Source string `json:"source,omitempty"`
Generated bool `json:"generated,omitempty"`
Ignored bool `json:"ignored,omitempty"`
// contains filtered or unexported fields
}
func (a *Asset) Open
func (a *Asset) Open() (io.ReadCloser, error)
type AssetOption
type AssetOption func(*assetOptions)
func AssetSource
func AssetSource(name string) AssetOption
func ContentType
func ContentType(contentType string) AssetOption
func ReplaceAsset
func ReplaceAsset() AssetOption
type CachePolicy
type CachePolicy string
type Manifest
type Manifest struct {
Assets []Asset `json:"assets"`
}
type OpenFunc
type OpenFunc func() (io.ReadCloser, error)
type Option
type Option func(*Options)
func WithCSSURLRewrite
func WithCSSURLRewrite(enabled bool) Option
func WithCachePolicies
func WithCachePolicies(logical, permanent CachePolicy) Option
func WithHashLength
func WithHashLength(length int) Option
func WithMaxAssetSize
func WithMaxAssetSize(size int64) Option
func WithOversizePolicy
func WithOversizePolicy(policy OversizePolicy) Option
func WithURLPrefix
func WithURLPrefix(prefix string) Option
type Options
type Options struct {
URLPrefix string
MaxAssetSize int64
OversizePolicy OversizePolicy
HashLength int
LogicalCache CachePolicy
PermanentCache CachePolicy
RewriteCSSURLs bool
}
type OversizePolicy
type OversizePolicy int
type Registry
type Registry struct {
// contains filtered or unexported fields
}
func New
func New(options ...Option) *Registry
func (r *Registry) Add
func (r *Registry) Add(path string, content []byte, options ...AssetOption) error
func (r *Registry) AddFS
func (r *Registry) AddFS(files fs.FS, options ...SourceOption) error
func (r *Registry) AddReader
func (r *Registry) AddReader(path string, open OpenFunc, options ...AssetOption) error
func (r *Registry) Empty
func (r *Registry) Empty() bool
func (r *Registry) Handler
func (r *Registry) Handler(next http.Handler) http.Handler
func (r *Registry) Helpers
func (r *Registry) Helpers() map[string]any
func (r *Registry) Integrity
func (r *Registry) Integrity(assetPath string) (string, error)
func (r *Registry) Manifest
func (r *Registry) Manifest() Manifest
func (r *Registry) MustPath
func (r *Registry) MustPath(assetPath string) string
func (r *Registry) Path
func (r *Registry) Path(assetPath string) (string, error)
func (r *Registry) ServeHTTP
func (r *Registry) ServeHTTP(w http.ResponseWriter, req *http.Request)
func (r *Registry) Unpack
func (r *Registry) Unpack(dir string, options ...UnpackOption) error
type Source
type Source interface {
Assets(*Registry) error
}
type SourceFunc
type SourceFunc func(*Registry) error
func (fn SourceFunc) Assets
func (fn SourceFunc) Assets(registry *Registry) error
type SourceOption
type SourceOption func(*sourceOptions)
func Replace
func Replace() SourceOption
func SourceName
func SourceName(name string) SourceOption
type UnpackMode
type UnpackMode int
type UnpackOption
type UnpackOption func(*unpackOptions)
func WithUnpackMode
func WithUnpackMode(mode UnpackMode) UnpackOption
Package lazyassets registers, fingerprints, and serves application assets.