Documentation
¶
Overview ¶
Package static provides a static-file handler for httpsrv.
New returns an httpsrv.Handler that serves files from a directory; register it on a catch-all route so it serves a whole file tree:
import "github.com/hooto/httpsrv/v2"
"github.com/hooto/httpsrv/v2/middleware/static"
app.Get("/static/{*path}", static.New("./assets"))
// GET /static/css/main.css -> ./assets/css/main.css
For an embedded filesystem use FS. The catch-all value (the part of the path after the prefix) is set by the httpsrv router under the conventional key "*" (fiber's c.Params("*") style), which the handler reads via r.PathValue("*"). Use app.All instead of app.Get to serve static files for every HTTP method.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.