Dir returns an http.FileSystem that can be used by http.FileServer(). It is used internally 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.
(root string, listDirectory bool)
| 40 | // if listDirectory == true, then it works the same as http.Dir(), |
| 41 | // otherwise it returns a filesystem that prevents http.FileServer() to list the directory files. |
| 42 | func Dir(root string, listDirectory bool) http.FileSystem { |
| 43 | fs := http.Dir(root) |
| 44 | |
| 45 | if listDirectory { |
| 46 | return fs |
| 47 | } |
| 48 | |
| 49 | return &OnlyFilesFS{FileSystem: fs} |
| 50 | } |
no outgoing calls