fs: Update documentation
This commit is contained in:
parent
46e10da3a8
commit
5ec8dea1ba
12
fs.go
12
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}
|
||||
}
|
||||
@ -42,15 +40,11 @@ func (fsh fsHandler) ServeGemini(w ResponseWriter, r *Request) {
|
||||
}
|
||||
|
||||
// FS represents a file system.
|
||||
//
|
||||
// TODO: Replace with io/fs.FS when available.
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user