Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Debug bool
Debug if pagecache module is in debug mode.
View Source
var PageCacheKeyHeader = "herbgo-debug-pagecache"
PageCacheKeyHeader http respnose header wihch will echo page cache key when debug is on.
Functions ¶
func FieldMiddleware ¶
func FieldMiddleware(FieldGenerator func(r *http.Request) *cache.Field, ttl time.Duration, statusValidator func(status int) bool) func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
FieldMiddleware create page cache middleare with given cache field,ttl,and status validator. Return middleware created.
Types ¶
type PageCache ¶
type PageCache struct {
Cache cache.Cacheable
KeyPrefix string
StatusValidator func(status int) bool
}
PageCache page cache struct
func (*PageCache) Middleware ¶
func (p *PageCache) Middleware(keyGenerator func(r *http.Request) string, ttl time.Duration) func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
Middleware create page cache middleware with give key generator and ttl. Return middleware created.
func (*PageCache) ValidateStatus ¶
ValidateStatus validate http status code if page should be cached. Return validated result. Page cache StatusValidator will be used.
Click to show internal directories.
Click to hide internal directories.