MustSubFS returns an [fs.FS] corresponding to the subtree rooted at fsys's dir. This is similar to [fs.Sub] but panics on failure.
(fsys fs.FS, dir string)
| 80 | // |
| 81 | // This is similar to [fs.Sub] but panics on failure. |
| 82 | func MustSubFS(fsys fs.FS, dir string) fs.FS { |
| 83 | dir = filepath.ToSlash(filepath.Clean(dir)) // ToSlash in case of Windows path |
| 84 | |
| 85 | sub, err := fs.Sub(fsys, dir) |
| 86 | if err != nil { |
| 87 | panic(fmt.Errorf("failed to create sub FS: %w", err)) |
| 88 | } |
| 89 | |
| 90 | return sub |
| 91 | } |
| 92 | |
| 93 | // Static is a handler function to serve static directory content from fsys. |
| 94 | // |
searching dependent graphs…