assets

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2020 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package assets hold utilities for serving static assets.

The actual assets live in auto subpackages instead of here, because the set of assets varies per program.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MimeTypeForFile

func MimeTypeForFile(file string) string

MimeTypeForFile returns the appropriate MIME type for an asset, based on the filename.

We use a built in table of the common types since the system TypeByExtension might be unreliable. But if we don't know, we delegate to the system. All our text files are in UTF-8.

func Serve

func Serve(w http.ResponseWriter, r *http.Request, asset Asset)

Serve writes a gzipped asset to w.

Types

type Asset

type Asset struct {
	ContentGz string    // gzipped contents of asset.
	Filename  string    // Original filename, determines Content-Type.
	Modified  time.Time // Determines ETag and Last-Modified.
}

Asset is the type of arguments to Serve.

Jump to

Keyboard shortcuts

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