httpasset

package
v0.0.0-...-a4b6567 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2019 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package httpasset provides a http.Handler that will serve files using the methods generated by go-bindata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(asset AssetAndInfo) http.Handler

New returns a new asset filesystem.

func NewCompressed

func NewCompressed(asset, compressed AssetAndInfo) http.Handler

NewCompressed returns a new asset filesystem that will optionally serve precompressed .gz and .br resources from compressed.

func NewCompressedWithETag

func NewCompressedWithETag(asset, compressed AssetAndInfo, etagLen int) http.Handler

NewCompressedWithETag returns a new asset filesystem that will optionally serve precompressed .gz and .br resources from compressed. It will include an ETag derived from the assets FileHash() if implemented.

func NewWithETag

func NewWithETag(asset AssetAndInfo, etagLen int) http.Handler

NewWithETag returns a new asset filesystem that will include an ETag derived from the assets FileHash() if implemented.

Types

type AssetAndInfo

type AssetAndInfo func(name string) (data []byte, info os.FileInfo, err error)

AssetAndInfo represents the generated AssetAndInfo method.

type FileServer

type FileServer struct {
	Asset  AssetAndInfo
	Brotli AssetAndInfo
	Gzip   AssetAndInfo

	EtagLen int
}

FileServer is a http.Handler that serves files from the provided AssetAndInfo methods.

It will serve files from Asset by default but will try to serve files from Brotli if the client supports brotli compression, or from Gzip if client only supports Gzip.

EtagLen optionally specifies the length of Etags to generate, if the os.FileInfo returned by Asset implements the FileHash() method. The Etag will be a hexadecimal encoded string truncated to EtagLen.

func (*FileServer) ServeHTTP

func (fs *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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