aboutsummaryrefslogtreecommitdiff
path: root/fs.go
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2021-01-14 22:24:26 -0500
committerAdnan Maolood <[email protected]>2021-01-14 22:24:26 -0500
commit8473f3b9d4d75e8936d3f5036584209b10a896b1 (patch)
treec9b25dfab3b490c0d688c1cf8d0372dd2ff22c1f /fs.go
parentserver: Rename Register to Handle (diff)
downloadgo-gemini-8473f3b9d4d75e8936d3f5036584209b10a896b1.tar.xz
go-gemini-8473f3b9d4d75e8936d3f5036584209b10a896b1.zip
fs: Update comments
Diffstat (limited to 'fs.go')
-rw-r--r--fs.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/fs.go b/fs.go
index a7cbd57..c7aa936 100644
--- a/fs.go
+++ b/fs.go
@@ -21,6 +21,8 @@ func init() {
// FileServer takes a filesystem and returns a Responder which uses that filesystem.
// The returned Responder sanitizes paths before handling them.
+//
+// TODO: Use io/fs.FS when available.
func FileServer(fsys FS) Responder {
return fsHandler{fsys}
}
@@ -44,12 +46,16 @@ func (fsh fsHandler) Respond(w *ResponseWriter, r *Request) {
_, _ = io.Copy(w, f)
}
-// TODO: replace with io/fs.FS when available
+// FS represents a filesystem.
+//
+// TODO: Replace with io/fs.FS when available
type FS interface {
Open(name string) (File, error)
}
-// TODO: replace with io/fs.File when available
+// File represents a file.
+//
+// TODO: Replace with io/fs.File when available.
type File interface {
Stat() (os.FileInfo, error)
Read([]byte) (int, error)
@@ -57,6 +63,8 @@ type File interface {
}
// Dir implements FS using the native filesystem restricted to a specific directory.
+//
+// TODO: replace with os.DirFS when available.
type Dir string
// Open tries to open the file with the given name.
@@ -68,6 +76,7 @@ func (d Dir) Open(name string) (File, error) {
// ServeFile responds to the request with the contents of the named file
// or directory.
+//
// TODO: Use io/fs.FS when available.
func ServeFile(w *ResponseWriter, fs FS, name string) {
f, err := fs.Open(name)