model

package
v0.0.0-...-dd818ff Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: AGPL-3.0 Imports: 6 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NameWithSum

func NameWithSum(name, sum string) string

NameWithSum returns the filename with its shasum

func NormalizeAssetName

func NormalizeAssetName(name string) string

NormalizeAssetName ensures the asset name always start with a "/"

Types

type Asset

type Asset struct {
	AssetOption
	Etag        string `json:"etag"`
	NameWithSum string `json:"name_with_sum"`
	Mime        string `json:"mime"`
	// contains filtered or unexported fields
}

Asset holds unzipped read-only file contents and file metadata.

func NewAsset

func NewAsset(opt AssetOption, rawData, brotliData []byte) *Asset

NewAsset creates a new asset

func (*Asset) BrotliReader

func (f *Asset) BrotliReader() *bytes.Reader

BrotliReader returns a bytes.Reader for the compressed content of the asset.

func (*Asset) BrotliSize

func (f *Asset) BrotliSize() string

BrotliSize returns the size of the compressed version of the asset.

func (*Asset) GetData

func (f *Asset) GetData() []byte

GetData returns the raw data as a slice of bytes.

func (*Asset) Reader

func (f *Asset) Reader() *bytes.Reader

Reader returns a bytes.Reader for the asset content (no compression).

func (*Asset) Size

func (f *Asset) Size() string

Size returns the size in bytes of the asset (no compression).

type AssetOption

type AssetOption struct {
	Name     string `json:"name"`
	Context  string `json:"context"`
	URL      string `json:"url"`
	Shasum   string `json:"shasum"`
	IsCustom bool   `json:"is_custom,omitempty"`
}

AssetOption is used to insert a dynamic asset.

Jump to

Keyboard shortcuts

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