feat(fs): Implement loading HTML from http.FileSystem (#4053)

* Implement loading HTML from http.FileSystem

* Add OnlyHTMLFS test

* Move OnlyHTMLFS to internal and add test
This commit is contained in:
sunshineplan
2025-04-21 00:11:16 +08:00
committed by GitHub
parent 0eb99493c2
commit 71496abe68
8 changed files with 258 additions and 18 deletions
+22
View File
@@ -0,0 +1,22 @@
package fs
import (
"io/fs"
"net/http"
)
// FileSystem implements an [fs.FS].
type FileSystem struct {
http.FileSystem
}
// Open passes `Open` to the upstream implementation and return an [fs.File].
func (o FileSystem) Open(name string) (fs.File, error) {
f, err := o.FileSystem.Open(name)
if err != nil {
return nil, err
}
return fs.File(f), nil
}