serve

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Overview

Package serve provides static file serving functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStaticFileHandler

func NewStaticFileHandler(debug bool, urlPrefix, staticUrl string, startupTime time.Time, fileProvider FileProvider) fasthttp.RequestHandler

NewStaticFileHandler returns a static handler for fasthttp with advanced caching and url prefix stripping.

func ServeFile

func ServeFile(w http.ResponseWriter, r *http.Request, f http.File)

ServeFile handles static file response.

Types

type File

type File interface {
	io.Closer
	io.Reader
	io.Seeker
	// Name returns abstract path of file.
	Name() string

	// Stat returns a os.FileInfo describing the named file.
	// If there is an error, it will be of type *os.PathError.
	Stat() (os.FileInfo, error)

	// Hash returns a file content checksum that is used for the e-tags.
	Hash() []byte
}

File defines a abstract file object,which provides caching hash.

type FileProvider

type FileProvider = func(name string) (File, error)

FileProvider is an alias of the file resolver function.

Jump to

Keyboard shortcuts

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