Documentation ΒΆ
Overview ΒΆ
Package hcfilters provides filtering middlewares for github.com/gregjones/httpcache.
message from the author:
+--------------------------------------------------------------+ | * * * ββββββββββββββββββββ Hello ββββββββββββββββββββββββββ| +--------------------------------------------------------------+ | | | ++ ______________________________________ | | ++++ / \ | | ++++ | | | | ++++++++++ | Feel free to contribute to this | | | +++ | | project or contact me on | | | ++ | | manfred.life if you like this | | | + -== ==| | project! | | | ( <*> <*> | | | | | | /| :) | | | | _) / | | | | | +++ / \______________________________________/ | | \ =+ / | | \ + | | |\++++++ | | | ++++ ||// | | ___| |___ _||/__ __| | / --- \ \| ||| __ _ ___ __ __/ /| |/ | | \ \ / / ' \/ _ \/ // / / | || | | | | | /_/_/_/\___/\_,_/_/ | +--------------------------------------------------------------+
This is how to wrap an existing backend:
before:
client := &http.Client{ Transport: httpcache.NewTransport( diskcache.New(diskcachePath), ), }
after:
client := &http.Client{ Transport: httpcache.NewTransport( hcfilters.MaxSize( // skip caching results > 2Mb diskcache.New(diskcachePath), 2*1024*1024, ), ), }
Index ΒΆ
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
This section is empty.
Types ΒΆ
type Cache ΒΆ
type Cache interface { // Get returns the []byte representation of a cached response and a bool // set to true if the value isn't empty Get(key string) (responseBytes []byte, ok bool) // Set stores the []byte representation of a response against a key Set(key string, responseBytes []byte) // Delete removes the value associated with the key Delete(key string) }
Cache is a clone of the httpcache.Cache struct to avoid having a dependency on the original repo
Click to show internal directories.
Click to hide internal directories.