Better documentation

This commit is contained in:
Manu Mtz-Almeida
2015-05-29 21:03:41 +02:00
parent 66e9feb622
commit 48633f7001
5 changed files with 41 additions and 4 deletions
+6
View File
@@ -14,6 +14,10 @@ type (
}
)
// It returns a http.Filesystem that can be used by http.FileServer(). It is used interally
// in router.Static().
// if listDirectory == true, then it works the same as http.Dir() otherwise it returns
// a filesystem that prevents http.FileServer() to list the directory files.
func Dir(root string, listDirectory bool) http.FileSystem {
fs := http.Dir(root)
if listDirectory {
@@ -23,6 +27,7 @@ func Dir(root string, listDirectory bool) http.FileSystem {
}
}
// Conforms to http.Filesystem
func (fs onlyfilesFS) Open(name string) (http.File, error) {
f, err := fs.fs.Open(name)
if err != nil {
@@ -31,6 +36,7 @@ func (fs onlyfilesFS) Open(name string) (http.File, error) {
return neuteredReaddirFile{f}, nil
}
// Overrides the http.File default implementation
func (f neuteredReaddirFile) Readdir(count int) ([]os.FileInfo, error) {
// this disables directory listing
return nil, nil