compressarch

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 11 Imported by: 0

README

Compress And Archive Package

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WORTH_COMPRESSING_CONTENT_TYPES = map[string]struct{}{
		mimeconsts.JS_CTYPE:   {},
		mimeconsts.CSS_CTYPE:  {},
		mimeconsts.JSON_CTYPE: {},
		mimeconsts.HTML_CTYPE: {},
	}
)

Functions

func UnGzip

func UnGzip(writer io.Writer, gzipped io.Reader) error

func UntarInMemory

func UntarInMemory(tarball io.Reader, entryCallbackFunc func(info fs.FileInfo, reader io.Reader) error) error

Types

type ContentCompressionParams

type ContentCompressionParams struct {
	Ctx           context.Context
	ContentReader io.Reader
	Path          string
	LastMtime     time.Time
}

type FileCompressor

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

A FileCompressor is a stateful file content compressor that uses GZip for compression and caches compressed files.

func NewFileCompressor

func NewFileCompressor() *FileCompressor

func (*FileCompressor) CompressFileContent

func (c *FileCompressor) CompressFileContent(args ContentCompressionParams) (_ io.ReadSeeker, isCompressed bool, _ error)

CompressFile compresses the file content if it's worth it. If the file is compressed the returned reader is not nil and isCompressed is true. Compressed content is cached for later use. An error is returned if .Ctx is done or if there was an error during compression. ContentReader may not be read at all and is never closed.

Jump to

Keyboard shortcuts

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