web

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: GPL-2.0 Imports: 11 Imported by: 0

README

default

Project setup

# yarn
yarn

# npm
npm install

# pnpm
pnpm install
Compiles and hot-reloads for development
# yarn
yarn dev

# npm
npm run dev

# pnpm
pnpm dev
Compiles and minifies for production
# yarn
yarn build

# npm
npm run build

# pnpm
pnpm build
Customize configuration

See Configuration Reference.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//go:embed all:dist
	Dist embed.FS

	DistDirFS = MustSubFS(Dist, "dist")
)

Functions

func FileFS

func FileFS(r *chi.Mux, path, file string, filesystem fs.FS)

FileFS registers a new route with path to serve a file from the provided file system.

func Index

func Index(w io.Writer, p IndexParams) error

func Manifest added in v0.2.7

func Manifest(w io.Writer, p IndexParams) error

func MustSubFS

func MustSubFS(currentFs fs.FS, fsRoot string) fs.FS

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

func StaticFS(r *chi.Mux, pathPrefix string, filesystem fs.FS)

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.

Types

type IndexParams

type IndexParams struct {
	Title   string
	Version string
	BaseUrl string
}

Jump to

Keyboard shortcuts

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