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

Method Static

echo.go:592–600  ·  view source on GitHub ↗

Static registers a new route with path prefix to serve static files from the provided root directory.

(pathPrefix, fsRoot string, middleware ...MiddlewareFunc)

Source from the content-addressed store, hash-verified

590
591// Static registers a new route with path prefix to serve static files from the provided root directory.
592func (e *Echo) Static(pathPrefix, fsRoot string, middleware ...MiddlewareFunc) RouteInfo {
593 subFs := MustSubFS(e.Filesystem, fsRoot)
594 return e.Add(
595 http.MethodGet,
596 pathPrefix+"*",
597 StaticDirectoryHandler(subFs, !e.enablePathUnescapingStaticFiles),
598 middleware...,
599 )
600}
601
602// StaticFS registers a new route with path prefix to serve static files from the provided file system.
603//

Calls 3

AddMethod · 0.95
MustSubFSFunction · 0.85
StaticDirectoryHandlerFunction · 0.85

Tested by 7

TestGroup_StaticFunction · 0.36
TestGroup_StaticPanicFunction · 0.36
TestEcho_StaticPanicFunction · 0.36
TestGzipWithStaticFunction · 0.36