cachestatic

package module
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2017 License: MIT Imports: 11 Imported by: 1

README

cachestatic

Build Status Coverage Status Go Report Card GoDoc

Cache Middleware for Golang

Documentation

Overview

Example
i := 0
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintf(w, "OK %d", i)
	i++
})

http.Handle("/", New(DefaultConfig)(h))
http.ListenAndServe(":8080", nil)
Output:

Index

Examples

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	Skipper:     middleware.DefaultSkipper,
	Indexer:     DefaultIndexer,
	Invalidator: nil,
	SkipHeaders: SkipHeaders(header.SetCookie),
}

DefaultConfig is the default config

View Source
var InvalidateAll interface{} = invalidateAll{}

InvalidateAll invalidates all cache items

Functions

func DefaultIndexer

func DefaultIndexer(r *http.Request) interface{}

DefaultIndexer is the default indexer function

func New

func New(c Config) func(http.Handler) http.Handler

New creates new cachestatic middleware

Types

type Config

type Config struct {
	Skipper     middleware.Skipper
	Indexer     Indexer
	Invalidator chan interface{}
	SkipHeaders SkipHeaderFunc
}

Config type

type Indexer added in v1.2.0

type Indexer func(*http.Request) interface{}

Indexer is the function for map request to cache index

func EncodingIndexer added in v1.2.0

func EncodingIndexer(encoding string) Indexer

EncodingIndexer creates an indexer for adds encoding into index

type SkipHeaderFunc added in v1.4.0

type SkipHeaderFunc func(string) bool

SkipHeaderFunc is the function to skip header, return true to skip

func SkipHeaders added in v1.4.0

func SkipHeaders(headers ...string) SkipHeaderFunc

SkipHeaders skips all given headers

Jump to

Keyboard shortcuts

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