MCPcopy
hub / github.com/labstack/echo / NewDefaultFS

Function NewDefaultFS

echo.go:873–878  ·  view source on GitHub ↗

NewDefaultFS returns a new defaultFS instance which allows `fs.FS.Open` to have absolute paths as input if it matches then given dir as prefix.

(dir string)

Source from the content-addressed store, hash-verified

871// NewDefaultFS returns a new defaultFS instance which allows `fs.FS.Open` to have absolute paths as input if it matches
872// then given dir as prefix.
873func NewDefaultFS(dir string) fs.FS {
874 return &defaultFS{
875 prefix: dir,
876 fs: os.DirFS(dir),
877 }
878}
879
880func (fs defaultFS) Open(name string) (fs.File, error) {
881 // fs.FS.Open() already assumes that file names are relative to FS root path and considers name with prefix `/` as invalid

Callers 2

TestNewDefaultFSFunction · 0.85
NewFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestNewDefaultFSFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…