MCPcopy
hub / github.com/gin-gonic/gin / Dir

Function Dir

fs.go:42–50  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
42func 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}

Callers 8

TestDir_listDirectoryFunction · 0.85
TestDirFunction · 0.85
testRoutesInterfaceFunction · 0.85
TestRouteStaticFileFSFunction · 0.85
StaticMethod · 0.85

Calls

no outgoing calls

Tested by 7

TestDir_listDirectoryFunction · 0.68
TestDirFunction · 0.68
testRoutesInterfaceFunction · 0.68
TestRouteStaticFileFSFunction · 0.68