requeststore

package module
v0.0.0-...-ab5cd8e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2018 License: BSD-3-Clause Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Clock = func() time.Time {
	return time.Now().UTC()
}
View Source
var DebugLogging = false
View Source
var ErrFoundInStore = errors.New("Found in store")
View Source
var ErrFoundInStorePrivate = errors.New("Found in store private")
View Source
var ErrFoundWithZeroInStore = errors.New("Found 0 size file in store")
View Source
var ErrNotFoundInStore = errors.New("Not found in store")

Returned when a resource doesn't exist

Functions

func CopyHeaders

func CopyHeaders(src, dst http.Header)

Types

type ByteReadSeekCloser

type ByteReadSeekCloser struct {
	*bytes.Reader
}

func (*ByteReadSeekCloser) Close

func (brsc *ByteReadSeekCloser) Close() error
type Header struct {
	http.Header
	StatusCode int
}

type IoReaderToReadSeekCloser

type IoReaderToReadSeekCloser struct {
	io.ReadCloser
}

func (*IoReaderToReadSeekCloser) Close

func (iosc *IoReaderToReadSeekCloser) Close() error

func (*IoReaderToReadSeekCloser) Seek

func (iosc *IoReaderToReadSeekCloser) Seek(offset int64, whence int) (int64, error)

type ReadSeekCloser

type ReadSeekCloser interface {
	io.Reader
	io.Seeker
	io.Closer
}

type Request

type Request struct {
	RequestTime time.Time
	// contains filtered or unexported fields
}

Request ---

func NewRequest

func NewRequest(req *http.Request) *Request

NewRequest ---

func (*Request) Header

func (r *Request) Header() http.Header

type Response

type Response struct {
	ReadSeekCloser
	RequestTime, ResponseTime time.Time
	// contains filtered or unexported fields
}

func NewResponse

func NewResponse(statusCode int, body ReadSeekCloser, hdrs http.Header) *Response

func NewResponseBytes

func NewResponseBytes(statusCode int, b []byte, hdrs http.Header) *Response

func NewResponseFromHttp

func NewResponseFromHttp(resp *http.Response, body io.ReadCloser) *Response

func (*Response) DateAfter

func (r *Response) DateAfter(d time.Time) bool

func (*Response) Expires

func (r *Response) Expires() (time.Time, error)

func (*Response) HasValidators

func (r *Response) HasValidators() bool

func (*Response) Header

func (r *Response) Header() http.Header

func (*Response) IsNonErrorStatus

func (r *Response) IsNonErrorStatus() bool

func (*Response) IsStale

func (r *Response) IsStale() bool

func (*Response) LastModified

func (r *Response) LastModified() time.Time

func (*Response) MarkStale

func (r *Response) MarkStale()

func (*Response) Status

func (r *Response) Status() int

func (*Response) Via

func (r *Response) Via() string

type Store

type Store interface {
	StoreRequest(h http.Request, key string, override bool) error
	StoreResponse(res *Response, key string, override bool) error
	StoreResponseHeader(res *Response, key string, override bool) error
	// StoreBody(h http.Request, key string, override bool) error
	RetrieveRequest(key string) (*http.Request, error)
	RetrieveRequestByHash(hash string) (*http.Request, error)
	RetrieveRequestByFileName(filename string) (*http.Request, error)
	RetrieveResponse(key string) (*Response, error)
	RetrieveResponseHeader(key string) (Header, error)
	// RetrieveResponseMetalink(key string, stored bool) (Metalink, error)
	DelRequest(key string) error
	DelResponse(key string) error
	DelResponseHeader(key string) error
	DelResponseBody(key string) error
	DelByFilename(filename string) error
	WalkRequests() ([]os.FileInfo, []string)
	RetrieveAllRequests() []http.Request
	FetchAndStoreResponse(h http.Request, key string, override bool) error
	HashKey(key string) string
}

Store ---

func NewDiskStore

func NewDiskStore(dir string) (Store, error)

NewDiskStore returns a disk-backed store

func NewMemoryStore

func NewMemoryStore() Store

NewMemoryStore returns an ephemeral store in memory

func NewVFSStore

func NewVFSStore(fs vfs.VFS) Store

NewVFSStore returns a store backend off the provided VFS

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址