buster

package module
v0.0.0-...-55d119b Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2016 License: MIT Imports: 7 Imported by: 0

README

Buster GoDoc

A Go file server used to bust static file caches on startup. This lets us set a very aggresive, 1 year cache control header and ensures that the client gets fresh files on statrup since the file path changes. If the client does request using an old file path the new file will be served.

Usage

See the example code for basic usage.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Buster = random(10)

Buster is used as the cache buster slug

Functions

func DefaultBuildBuster

func DefaultBuildBuster(s *FileServer) string

func DefaultBuildURL

func DefaultBuildURL(path string, s *FileServer) string

func DefaultStripBuster

func DefaultStripBuster(p string, s *FileServer) (string, bool)

Types

type FileServer

type FileServer struct {
	RootDir      string // File system directory that will be served
	Prefix       string // URL prefix
	Buster       string // Cache buster that will be added to the Prefix
	Host         string // include for absolute urls (example http://example.com)
	DisableCache bool   // don't cache

	BuildBusterFunc func(s *FileServer) string                      // func used to build the path prefix
	StripBusterFunc func(path string, s *FileServer) (string, bool) // func used to strip the prefix
	BuildURLFunc    func(path string, s *FileServer) string         // func use to create URLs with the cache buster
	// contains filtered or unexported fields
}

func NewFileServer

func NewFileServer(rootDir, prefix string) *FileServer

func (*FileServer) BuildURL

func (fs *FileServer) BuildURL(url string) string

BuildURL

func (*FileServer) GinFunc

func (s *FileServer) GinFunc() gin.HandlerFunc

GinFunc returns a gin middleware func

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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