...

Source file src/github.com/linkerd/linkerd2/pkg/filesonly/filesonly.go

Documentation: github.com/linkerd/linkerd2/pkg/filesonly

     1  package filesonly
     2  
     3  /* An implementation of the http.FileSystem interface that disallows
     4     listing the contents of directories. This approach is adapted from:
     5  	 https://groups.google.com/d/topic/golang-nuts/bStLPdIVM6w/discussion
     6  
     7  	 Source: https://github.com/BuoyantIO/util
     8  */
     9  
    10  import (
    11  	"net/http"
    12  	"os"
    13  )
    14  
    15  // FileSystem provides access to a collection of named files via
    16  // http.FileSystem, given a directory.
    17  func FileSystem(dir string) http.FileSystem {
    18  	return fileSystem{http.Dir(dir)}
    19  }
    20  
    21  type fileSystem struct {
    22  	fs http.FileSystem
    23  }
    24  
    25  func (fs fileSystem) Open(name string) (http.File, error) {
    26  	f, err := fs.fs.Open(name)
    27  	if err != nil {
    28  		return nil, err
    29  	}
    30  	return file{f}, nil
    31  }
    32  
    33  type file struct {
    34  	http.File
    35  }
    36  
    37  func (f file) Readdir(count int) ([]os.FileInfo, error) {
    38  	return nil, nil
    39  }
    40  

View as plain text