Documentation
¶
Index ¶
- Constants
- type CacheHandler
- func NewRoundtrip(defaultRoundTripper http.RoundTripper, cacheActor cache.ICacheInteractor) *CacheHandler
- func NewWithCustomStorageCache(client *http.Client, cacheInteractor cache.ICacheInteractor) (cacheHandler *CacheHandler, err error)
- func NewWithInmemoryCache(client *http.Client, duration ...time.Duration) (cachedHandler *CacheHandler, err error)
Constants ¶
View Source
const ( HeaderAuthorization = "Authorization" HeaderCacheControl = "Cache-Control" // To indicate that the response is got from this httpcache library XFromHache = "X-HTTPCache" XHacheOrigin = "X-HTTPCache-Origin" )
Headers
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheHandler ¶
type CacheHandler struct {
DefaultRoundTripper http.RoundTripper
CacheInteractor cache.ICacheInteractor
}
CacheHandler custom plugable' struct of implementation of the http.RoundTripper
func NewRoundtrip ¶
func NewRoundtrip(defaultRoundTripper http.RoundTripper, cacheActor cache.ICacheInteractor) *CacheHandler
NewRoundtrip will create an implementations of cache http roundtripper
func NewWithCustomStorageCache ¶
func NewWithCustomStorageCache(client *http.Client, cacheInteractor cache.ICacheInteractor) (cacheHandler *CacheHandler, err error)
NewWithCustomStorageCache will initiate the httpcache with your defined cache storage To use your own cache storage handler, you need to implement the cache.Interactor interface And pass it to httpcache.
func NewWithInmemoryCache ¶
func NewWithInmemoryCache(client *http.Client, duration ...time.Duration) (cachedHandler *CacheHandler, err error)
NewWithInmemoryCache will create a complete cache-support of HTTP client with using inmemory cache. If the duration not set, the cache will use LFU algorithm
Click to show internal directories.
Click to hide internal directories.