Documentation
¶
Index ¶
- type EmbedFSProvider
- type LocalFSProvider
- func (p *LocalFSProvider) Close() error
- func (p *LocalFSProvider) Open(name string) (fs.File, error)
- func (p *LocalFSProvider) Path() string
- func (p *LocalFSProvider) Reload() error
- func (p *LocalFSProvider) StripPrefix() string
- func (p *LocalFSProvider) Type() string
- func (p *LocalFSProvider) WithStripPrefix(prefix string)
- type ZipFSProvider
- func (p *ZipFSProvider) Close() error
- func (p *ZipFSProvider) Open(name string) (fs.File, error)
- func (p *ZipFSProvider) Path() string
- func (p *ZipFSProvider) Reload() error
- func (p *ZipFSProvider) StripPrefix() string
- func (p *ZipFSProvider) Type() string
- func (p *ZipFSProvider) WithStripPrefix(prefix string)
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) 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) 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".