providers

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmbedFSProvider

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

EmbedFSProvider serves files from an embedded filesystem. It supports both direct embedded directories and embedded zip files.

func NewEmbedFSProvider

func NewEmbedFSProvider(embedFS fs.FS, zipFile string) (*EmbedFSProvider, error)

NewEmbedFSProvider creates a new EmbedFSProvider. If zipFile is empty, the embedded FS is used directly. If zipFile is specified, it's treated as a path to a zip file within the embedded FS.

func (*EmbedFSProvider) Close

func (p *EmbedFSProvider) Close() error

Close releases any resources held by the provider. For embedded filesystems, this is mostly a no-op since Go manages the lifecycle.

func (*EmbedFSProvider) Open

func (p *EmbedFSProvider) Open(name string) (fs.File, error)

Open opens the named file from the embedded filesystem.

func (*EmbedFSProvider) Type

func (p *EmbedFSProvider) Type() string

Type returns "embed" or "embed-zip" depending on the configuration.

func (*EmbedFSProvider) ZipFile

func (p *EmbedFSProvider) ZipFile() string

ZipFile returns the path to the zip file within the embedded FS, if any.

type LocalFSProvider

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

LocalFSProvider serves files from a local directory.

func NewLocalFSProvider

func NewLocalFSProvider(path string) (*LocalFSProvider, error)

NewLocalFSProvider creates a new LocalFSProvider for the given directory path. The path must be an absolute path to an existing directory.

func (*LocalFSProvider) Close

func (p *LocalFSProvider) Close() error

Close releases any resources held by the provider. For local filesystem, this is a no-op since os.DirFS doesn't hold resources.

func (*LocalFSProvider) Open

func (p *LocalFSProvider) Open(name string) (fs.File, error)

Open opens the named file from the local directory.

func (*LocalFSProvider) Path

func (p *LocalFSProvider) Path() string

Path returns the absolute path to the directory being served.

func (*LocalFSProvider) Reload

func (p *LocalFSProvider) Reload() error

Reload refreshes the filesystem view. For local directories, os.DirFS automatically picks up changes, so this recreates the DirFS to ensure a fresh view.

func (*LocalFSProvider) Type

func (p *LocalFSProvider) Type() string

Type returns "local".

type ZipFSProvider

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

ZipFSProvider serves files from a zip file.

func NewZipFSProvider

func NewZipFSProvider(zipPath string) (*ZipFSProvider, error)

NewZipFSProvider creates a new ZipFSProvider for the given zip file path.

func (*ZipFSProvider) Close

func (p *ZipFSProvider) Close() error

Close releases resources held by the zip reader.

func (*ZipFSProvider) Open

func (p *ZipFSProvider) Open(name string) (fs.File, error)

Open opens the named file from the zip archive.

func (*ZipFSProvider) Path

func (p *ZipFSProvider) Path() string

Path returns the absolute path to the zip file being served.

func (*ZipFSProvider) Reload

func (p *ZipFSProvider) Reload() error

Reload reopens the zip file to pick up any changes. This is useful in development when the zip file is updated.

func (*ZipFSProvider) Type

func (p *ZipFSProvider) Type() string

Type returns "zip".

Jump to

Keyboard shortcuts

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