providers

package
v1.0.99 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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. Use WithStripPrefix to configure path prefix stripping.

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. If a strip prefix is configured, it prepends the prefix to the requested path. For example, with stripPrefix="/dist", requesting "/assets/style.css" will open "/dist/assets/style.css" from the embedded filesystem.

func (*EmbedFSProvider) StripPrefix added in v1.0.12

func (p *EmbedFSProvider) StripPrefix() string

StripPrefix returns the configured strip prefix.

func (*EmbedFSProvider) Type

func (p *EmbedFSProvider) Type() string

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

func (*EmbedFSProvider) WithStripPrefix added in v1.0.12

func (p *EmbedFSProvider) WithStripPrefix(prefix string)

WithStripPrefix sets the prefix to strip from requested paths. For example, WithStripPrefix("/dist") will make files at "/dist/assets" accessible via "/assets".

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. If a strip prefix is configured, it prepends the prefix to the requested path. For example, with stripPrefix="/dist", requesting "/assets/style.css" will open "/dist/assets/style.css" from the local filesystem.

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) StripPrefix added in v1.0.13

func (p *LocalFSProvider) StripPrefix() string

StripPrefix returns the configured strip prefix.

func (*LocalFSProvider) Type

func (p *LocalFSProvider) Type() string

Type returns "local".

func (*LocalFSProvider) WithStripPrefix added in v1.0.13

func (p *LocalFSProvider) WithStripPrefix(prefix string)

WithStripPrefix sets the prefix to strip from requested paths. For example, WithStripPrefix("/dist") will make files at "/dist/assets" accessible via "/assets".

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. If a strip prefix is configured, it prepends the prefix to the requested path. For example, with stripPrefix="/dist", requesting "/assets/style.css" will open "/dist/assets/style.css" from the zip filesystem.

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) StripPrefix added in v1.0.13

func (p *ZipFSProvider) StripPrefix() string

StripPrefix returns the configured strip prefix.

func (*ZipFSProvider) Type

func (p *ZipFSProvider) Type() string

Type returns "zip".

func (*ZipFSProvider) WithStripPrefix added in v1.0.13

func (p *ZipFSProvider) WithStripPrefix(prefix string)

WithStripPrefix sets the prefix to strip from requested paths. For example, WithStripPrefix("/dist") will make files at "/dist/assets" accessible via "/assets".

Jump to

Keyboard shortcuts

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