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

Method StaticFS

echo.go:607–614  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

605// prefix for directory path. This is necessary as `//go:embed assets/images` embeds files with paths
606// including `assets/images` as their prefix.
607func (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.

Calls 2

AddMethod · 0.95
StaticDirectoryHandlerFunction · 0.85