I'm using the built in static file http.FileServer.Do you know if there is an easy way to disable the directory listing? Just simply return a 404.
--
I've settled on the following, which has the added benefit of returning 404 for directories.
Corrections appreciated.
type justFilesFilesystem struct {
Fs http.FileSystem
}
func (fs justFilesFilesystem) Open(name string) (http.File, error) {
f, err := fs.Fs.Open(name)
if err != nil {
return nil, err
}
stat, err := f.Stat()
if stat.IsDir() {
return nil, os.ErrNotExist
}
return f, nil
}