gocdn

package module
v0.0.0-...-0d2de64 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2015 License: MPL-2.0 Imports: 9 Imported by: 1

README

GoDoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CDN

type CDN struct {
	Prefix        string
	CacheDuration int
	Cors          bool
	CacheDir      string
	UseFileCache  bool
}

CDN does stuff

func (*CDN) Handler

func (c *CDN) Handler(w http.ResponseWriter, r *http.Request)

Handler implements a standard interface for http.HandleFunc

type CDNFile

type CDNFile struct {
	Package      string
	Version      string
	Path         string
	Extension    string
	Mime         string
	CacheDir     string
	UseFileCache bool
}

CDNFile is a struct which contains necessary information regarding a static file. The related methods allow for fetching and serving that file via various CDN's.

func (*CDNFile) CacheToDisk

func (f *CDNFile) CacheToDisk(content []byte)

CacheToDisk writes the content to disk.

func (*CDNFile) GetUrls

func (f *CDNFile) GetUrls() []string

GetUrls returns a set of possible locations for each file based on available CDNs.

func (*CDNFile) Query

func (f *CDNFile) Query() <-chan Query

Query returns the file contents in []byte for each file. It loops through the possible file URL's, and returns the first result. URL's which have errors, don't exist, etc., block forever.

type Query

type Query struct {
	StausCode int
	Cached    bool
	URL       string
	Path      string
	Bytes     []byte
	Size      int
	Duration  time.Duration
}

Query holds data related to a file lookup. This includes where it came from, it's size, contents, etc.

Jump to

Keyboard shortcuts

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