static

package
v2.0.0-beta.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

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

func FS

FS returns a handler that serves files from fs (e.g. http.FS(anEmbed.FS)) for serving embedded content.

func New

func New(root string) httpsrv.Handler

New returns a handler that serves files from the directory at root, mirroring gofiber v3's static.New(root) -> Handler. Path escape is prevented by http.Dir. Register it on a catch-all route, e.g. app.Get("/static/{*path}", static.New("./assets")).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL