files

package
v0.0.0-...-9ff5dc0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: AGPL-3.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdaptToHTTPFileSystem

func AdaptToHTTPFileSystem(fs FileSystem, directoryListings bool) http.FileSystem

AdaptToHTTPFileSystem converts any FileSystem implementation into one that can be used with http.FileServer

func PipeTo

func PipeTo(fs FileSystem, filePath string, reader io.Reader) error

Types

type ByteTransformer

type ByteTransformer = func(original []byte)

type FileSystem

type FileSystem interface {
	MkdirAll(dirPath string, perm os.FileMode) error
	Create(name string) (WriteableFile, error)
	Remove(name string) error
	Stat(name string) (os.FileInfo, error)
	IsNotExist(err error) bool
	Open(path string) (ReadableFile, error)
}

FileSystem is an abstract file read/write interface

func LocalFileSystem

func LocalFileSystem(dir string) FileSystem

LocalFileSystem provides access to things in a local directory

func TransformFileSystem

func TransformFileSystem(fs FileSystem, transformer ByteTransformer) FileSystem

type ReadableFile

type ReadableFile interface {
	io.ReadCloser
	io.Seeker
	Readdir(count int) ([]os.FileInfo, error)
	Stat() (os.FileInfo, error)
}

ReadableFile is a file that we can read data from

type SPAFileSystem

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

SPAFileSystem responds with the given fallback file if the requested path does not exist.

func CreateSPAFileSystem

func CreateSPAFileSystem(fs http.FileSystem, fallback string) SPAFileSystem

CreateSPAFileSystem that falls back to `fallback`

func (SPAFileSystem) Open

func (fs SPAFileSystem) Open(name string) (http.File, error)

Open a file, or respond with the fallback contents

type WriteableFile

type WriteableFile interface {
	io.WriteCloser
}

WriteableFile is a file that we can write data to

Jump to

Keyboard shortcuts

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