StaticFS registers a new route with path prefix to serve static files from the provided file system. When dealing with `embed.FS` use `fs := echo.MustSubFS(fs, "rootDirectory") to create sub fs which uses necessary prefix for directory path. This is necessary as `//go:embed assets/images` embeds fi
(pathPrefix string, filesystem fs.FS, middleware ...MiddlewareFunc)
| 605 | // prefix for directory path. This is necessary as `//go:embed assets/images` embeds files with paths |
| 606 | // including `assets/images` as their prefix. |
| 607 | func (e *Echo) StaticFS(pathPrefix string, filesystem fs.FS, middleware ...MiddlewareFunc) RouteInfo { |
| 608 | return e.Add( |
| 609 | http.MethodGet, |
| 610 | pathPrefix+"*", |
| 611 | StaticDirectoryHandler(filesystem, !e.enablePathUnescapingStaticFiles), |
| 612 | middleware..., |
| 613 | ) |
| 614 | } |
| 615 | |
| 616 | // StaticDirectoryHandler creates handler function to serve files from provided file system |
| 617 | // When disablePathUnescaping is set then file name from path is not unescaped and is served as is. |