Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCacheExpired error = errors.New("cache expired")
ErrCacheExpired is returned if the cache is expired
View Source
var ErrCacheNotFound error = errors.New("cache not found")
ErrCacheNotFound is returned when the cache is not found
View Source
var ErrShouldNotUseCache error = errors.New("should not use cache")
ErrShouldNotUseCache is returned if should not use cache
Functions ¶
Types ¶
type Cacher ¶
type Cacher interface { // Load loads the request/response cache. // If the cache is not found, it returns ErrCacheNotFound. // If the cache is expired, it returns ErrCacheExpired. // If not caching, it returns ErrShouldNotUseCache. Load(req *http.Request) (cachedReq *http.Request, cachedRes *http.Response, err error) // Store stores the response cache. Store(req *http.Request, res *http.Response, expires time.Time) error }
type Handler ¶
type Handler interface { // Handle handles the request/response cache. Handle(req *http.Request, cachedReq *http.Request, cachedRes *http.Response, originRequester func(*http.Request) (*http.Response, error), now time.Time) (cacheUsed bool, res *http.Response, err error) // Storable returns whether the response is storable and the expiration time. Storable(req *http.Request, res *http.Response, now time.Time) (ok bool, expires time.Time) }
type Option ¶ added in v0.6.0
type Option func(*cacheMw)
func HeaderNamesToMask ¶ added in v0.9.4
HeaderNamesToMask sets header names to mask in logs.
func UseRequestBody ¶ added in v0.9.1
func UseRequestBody() Option
UseRequestBody enables to use request body as cache key.
func WithLogger ¶ added in v0.6.0
WithLogger sets logger (slog.Logger).
Click to show internal directories.
Click to hide internal directories.