aboutsummaryrefslogtreecommitdiff
path: root/fs.go
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2021-02-14 19:27:56 -0500
committerAdnan Maolood <[email protected]>2021-02-14 19:27:56 -0500
commit5ec8dea1ba1ba41cb6b0c231a6cdeb761949ab06 (patch)
treeff83b612da9cfac10f9c6431c3816f2550a5c144 /fs.go
parentMake Request.Host optional (diff)
downloadgo-gemini-5ec8dea1ba1ba41cb6b0c231a6cdeb761949ab06.tar.xz
go-gemini-5ec8dea1ba1ba41cb6b0c231a6cdeb761949ab06.zip
fs: Update documentation
Diffstat (limited to 'fs.go')
-rw-r--r--fs.go14
1 files changed, 2 insertions, 12 deletions
diff --git a/fs.go b/fs.go
index 56d1432..d282edc 100644
--- a/fs.go
+++ b/fs.go
@@ -14,10 +14,8 @@ func init() {
}
// FileServer returns a handler that serves Gemini requests with the contents
-// of the file system rooted at root.
+// of the provided file system.
// The returned handler cleans paths before handling them.
-//
-// TODO: Use io/fs.FS when available.
func FileServer(fsys FS) Handler {
return fsHandler{fsys}
}
@@ -41,16 +39,12 @@ func (fsh fsHandler) ServeGemini(w ResponseWriter, r *Request) {
_, _ = io.Copy(w, f)
}
-// FS represents a filesystem.
-//
-// TODO: Replace with io/fs.FS when available.
+// FS represents a file system.
type FS interface {
Open(name string) (File, error)
}
// File represents a file.
-//
-// TODO: Replace with io/fs.File when available.
type File interface {
Stat() (os.FileInfo, error)
Read([]byte) (int, error)
@@ -58,8 +52,6 @@ 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.
@@ -71,8 +63,6 @@ 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)
if err != nil {