MCPcopy Index your code
hub / github.com/labstack/echo / MustSubFS

Function MustSubFS

echo.go:919–925  ·  view source on GitHub ↗

MustSubFS creates sub FS from current filesystem or panic on failure. Panic happens when `fsRoot` contains invalid path according to `fs.ValidPath` rules. MustSubFS is helpful when dealing with `embed.FS` because for example `//go:embed assets/images` embeds files with paths including `assets/image

(currentFs fs.FS, fsRoot string)

Source from the content-addressed store, hash-verified

917// paths including `assets/images` as their prefix. In that case use `fs := echo.MustSubFS(fs, "rootDirectory") to
918// create sub fs which uses necessary prefix for directory path.
919func MustSubFS(currentFs fs.FS, fsRoot string) fs.FS {
920 subFs, err := subFS(currentFs, fsRoot)
921 if err != nil {
922 panic(fmt.Errorf("can not create sub FS, invalid root given, err: %w", err))
923 }
924 return subFs
925}
926
927func sanitizeURI(uri string) string {
928 // double slash `\\`, `//` or even `\/` is absolute uri for browsers and by redirecting request to that uri

Callers 3

StaticMethod · 0.85
TestEcho_StaticFSFunction · 0.85
StaticMethod · 0.85

Calls 1

subFSFunction · 0.85

Tested by 1

TestEcho_StaticFSFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…