Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
func Middleware(config *Config, cache CacheInterface) echo.MiddlewareFunc
Middleware creates a middleware to handle cache
func MiddlewareV4 ¶ added in v0.0.5
func MiddlewareV4(config *Config, cache CacheInterface) echo4.MiddlewareFunc
MiddlewareV4 creates a middleware to handle cache for echo V4
Types ¶
type CacheInterface ¶
type CacheInterface interface { Get(key string) ([]byte, error) Set(key string, value []byte) error Delete(key string) error Reset() error }
CacheInterface defines interface for cache
type Config ¶
type Config struct { // Enabled to enable/disable cacheman Enabled bool // Verbose allow activities of cacheman to be display on console Verbose bool // TTL is age of cache entry in duration format, e.g. 1d for one day TTL string // Paths that will be cached Paths []string // ExcludedPaths are paths to be excluded from cache ExcludedPaths []string // AdditionalHeaders are injected in return cache AdditionalHeaders map[string]string }
Config for cacheman
type Content ¶
type Content struct { Status int `json:"status"` Headers http.Header `json:"headers"` Content string `json:"content"` }
Content is cached content
type Interceptor ¶
type Interceptor struct {
// contains filtered or unexported fields
}
Interceptor is response interceptor
func NewInterceptor ¶
func NewInterceptor(writer http.ResponseWriter) *Interceptor
NewInterceptor creates a new response interceptor
func (*Interceptor) Content ¶
func (c *Interceptor) Content() []byte
Content returns the captured content
func (*Interceptor) Header ¶
func (c *Interceptor) Header() http.Header
Header returns response header
func (*Interceptor) Write ¶
func (c *Interceptor) Write(b []byte) (int, error)
Write writes out the content. Automatically writes out the header if it has not been written out.
func (*Interceptor) WriteHeader ¶
func (c *Interceptor) WriteHeader(statusCode int)
WriteHeader writes out the header with given status code
type Manager ¶
type Manager struct { Enabled bool Verbose bool Cache CacheInterface Routes []string ExcludedRoutes []string RouteCount int ExcludedRouteCount int ComparableRoutes []*regexp.Regexp ComparableExcludedRoutes []*regexp.Regexp AdditionalHeaders map[string]string }
Manager is cache manager
func NewCacheManager ¶
func NewCacheManager(conf *Config, cache CacheInterface) *Manager
NewCacheManager creates a cache manager
Click to show internal directories.
Click to hide internal directories.