Documentation ¶
Overview ¶
Package web web/build.go
Index ¶
- Variables
- func FileFS(r *chi.Mux, path, file string, filesystem fs.FS)
- func Index(w io.Writer, p IndexParams) error
- func Manifest(w io.Writer, p IndexParams) error
- func MustSubFS(currentFs fs.FS, fsRoot string) fs.FS
- func RegisterHandler(c *chi.Mux, version, baseUrl string)
- func StaticFS(r *chi.Mux, pathPrefix string, filesystem fs.FS)
- func StaticFileHandler(file string, filesystem fs.FS) http.HandlerFunc
- type IndexParams
Constants ¶
This section is empty.
Variables ¶
var ( //go:embed all:dist Dist embed.FS DistDirFS = MustSubFS(Dist, "dist") )
Functions ¶
func MustSubFS ¶
MustSubFS creates sub FS from current filesystem or panic on failure. Panic happens when `fsRoot` contains invalid path according to `fs.ValidPath` rules.
MustSubFS is helpful when dealing with `embed.FS` because for example `//go:embed assets/images` embeds files with paths including `assets/images` as their prefix. In that case use `fs := MustSubFS(fs, "rootDirectory") to create sub fs which uses necessary prefix for directory path.
func RegisterHandler ¶
func RegisterHandler(c *chi.Mux, version, baseUrl string)
RegisterHandler register web routes and file serving
func StaticFS ¶
StaticFS registers a new route with path prefix to serve static files from the provided file system.
func StaticFileHandler ¶
func StaticFileHandler(file string, filesystem fs.FS) http.HandlerFunc
StaticFileHandler creates a handler function to serve a file from the provided file system.