Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TeeReadCloser ¶
func TeeReadCloser(r io.ReadCloser, w io.WriteCloser, callback func()) io.ReadCloser
TeeReadCloser is an io.TeeReader that also closes, and calls the callback after all streams are closed. The callback is only called if there were no errors closing the reader. This is so that if the connection is severed or the file is corrupted we don't cache. If there's a problem with the writer, it finishes reading still and skips the callback. That way if the disk is full we don't cache but the read is successful.
func WasResponseCached ¶
WasResponseCached returns true if the response was cached.
Types ¶
type DB ¶
DB contains the metadata of the disk cache
func (*DB) OnRequest ¶
OnRequest checks to see if the response is cached, if so responds with the cached data.
func (*DB) OnResponse ¶
OnResponse caches the data in the DB and writes the data to disk.
func (*DB) WriteToDisk ¶
WriteToDisk outputs the db in the cache directory for scenario use.
type Entry ¶
type Entry struct {
Status int `yaml:"status"`
FilePath string `yaml:"filePath"`
ResponseHeaders http.Header `yaml:"responseHeaders,omitempty"`
// only set with PROXY_DEBUG_HEADERS=true
RequestHeaders http.Header `yaml:"requestHeaders,omitempty"`
}
Entry is an entry of the DB