spa

package
v4.0.14 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Handler = func(prefix string, dir fs.FS) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		f := http.StripPrefix(prefix, http.FileServer(http.FS(dir)))
		if _, err := fs.Stat(dir, strings.TrimPrefix(r.RequestURI, prefix)); err != nil {
			r.RequestURI = prefix
			r.URL.Path = prefix
		}
		f.ServeHTTP(w, r)
	}
}

Handler serve files from dir and redirect to index if file not exists

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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