feat(staticweb): add path prefix stripping to all filesystem providers

Add PrefixStrippingProvider interface and implement it in all providers
(EmbedFSProvider, LocalFSProvider, ZipFSProvider) to support serving
files from subdirectories at the root level.
This commit is contained in:
2026-01-03 14:39:51 +02:00
parent d33747c2d3
commit 2017465cb8
4 changed files with 112 additions and 11 deletions

View File

@@ -142,12 +142,10 @@ func (p *EmbedFSProvider) ZipFile() string {
// WithStripPrefix sets the prefix to strip from requested paths.
// For example, WithStripPrefix("/dist") will make files at "/dist/assets"
// accessible via "/assets".
// Returns the provider for method chaining.
func (p *EmbedFSProvider) WithStripPrefix(prefix string) *EmbedFSProvider {
func (p *EmbedFSProvider) WithStripPrefix(prefix string) {
p.mu.Lock()
defer p.mu.Unlock()
p.stripPrefix = prefix
return p
}
// StripPrefix returns the configured strip prefix.