tarserv

package
v0.0.0-...-c2fc523 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: CC0-1.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoDir = errors.New("no directory")

ErrNoDir is returned if a given path is not a directory.

View Source
var OptAbsolute = new(optAbsolute)

OptAbsolute will rebase the tar file for absolute original paths.

View Source
var OptNumericIDs = new(optNumericIDs)

OptNumericIDs sets all IDs to numeric.

View Source
var OptRelative = new(optRelative)

OptRelative will rebase the tar file to relative paths.

Functions

func NewTar

func NewTar(dir string, w io.Writer, options ...Option) error

NewTar creates a tar stream written to w that contains dir. It will have paths as determined by pathType.

func OptAppendFile

func OptAppendFile(name string, mode os.FileMode, r io.Reader) appendFileOpt

OptAppendFile appends a file to the tar with the given name and content read from r.

func OptGID

func OptGID(gid int) setGIDOption

OptGID sets all file group IDs to uid.

func OptUID

func OptUID(uid int) setUIDOption

OptUID sets all file user IDs to uid.

func Serve

func Serve(address, prefix, sourceDir, appendFilename string) error

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is an option for tarfile creation.

func OptByteSeek

func OptByteSeek(firstFile string, skipBytes int64) Option

func OptRebase

func OptRebase(dir string) Option

OptRebase returns an Option that rebases the tar entries to dir.

type PathFunc

type PathFunc func(base string) PathRewriteFunc

PathFunc creates a function for rewriting paths.

type PathRewriteFunc

type PathRewriteFunc func(d string) string

PathRewriteFunc rewrites a path.

type TarHandler

type TarHandler struct {
	SourceDir      string
	AppendFileName string
}

TarHandler is a http.Handler that serves a sub-directory of SourceDir (only last

func (*TarHandler) Handler

func (handler *TarHandler) Handler(w http.ResponseWriter, r *http.Request)

func (*TarHandler) ServeHTTP

func (handler *TarHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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