Documentation ¶
Index ¶
- func Embed(opts Options) error
- func Handle(prefix string, resources ...*Resource) func(http.ResponseWriter, *http.Request)
- type Bundle
- type Filesystem
- type Options
- type Resource
- func (r *Resource) AsBytes() []byte
- func (r *Resource) AsString() string
- func (r *Resource) IsDir() bool
- func (r *Resource) ModTime() time.Time
- func (r *Resource) Mode() os.FileMode
- func (r *Resource) Name() string
- func (r *Resource) Read() io.Reader
- func (r *Resource) ReadBrotli() io.Reader
- func (r *Resource) ReadGzip() io.Reader
- func (r *Resource) Size() int64
- func (r *Resource) Sys() interface{}
- func (r *Resource) Version() string
- func (r *Resource) Write(dst io.Writer) (int, error)
- func (r *Resource) WriteBrotli(dst io.Writer) (int, error)
- func (r *Resource) WriteGzip(dst io.Writer) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Embed ¶
Embed includes the given files or folders and creates a new go src file. It expects a working dir somewhere within a go module and picks the root itself.
Types ¶
type Bundle ¶
type Bundle struct {
// contains filtered or unexported fields
}
Bundle contains a bunch of resources.
func Make ¶
Make creates a new bundle from the given resources. We use Make here to avoid stuttering like bundle.NewBundle(). Takes ownership of resources.
func (*Bundle) Handler ¶
Handler returns a new http handler, providing resources for the given prefix
type Filesystem ¶
type Filesystem struct {
// contains filtered or unexported fields
}
Filesystem is an implementation on top of the bundle resources. However better use the handler, which returns handles compression better.
func NewFilesystem ¶
func NewFilesystem(resources ...*Resource) *Filesystem
type Options ¶
type Options struct { TargetDir string PackageName string Include []string StripPrefixes []string // removes this prefix from all Include paths, if they begin with it Prefix string // attach this prefix to all included files IgnoreRegex string // e.g. '.*\.map|^\..*' will ignore all map and hidden files from inclusion DisableCacheUnpacked bool DisableCacheGzip bool DisableCacheBrotli bool }
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
A Resource relates a bunch of bytes with a name and optionally cached variants of the same data.
func NewResource ¶
func NewResourceFromBytes ¶
NewResourceFromBytes creates a new resource for the given buffer
func (*Resource) ReadBrotli ¶
ReadGzip opens the resource to read the data as gzip stream
func (*Resource) WriteBrotli ¶
WriteBrotli writes the datastream as a brotli buffer into the writer