roundtripper

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

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

Go to latest
Published: Apr 3, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const CacheExpirationHeader = "x-httpclient-cache-expiration"

Variables

This section is empty.

Functions

func DefaultKeyFunc

func DefaultKeyFunc(req *http.Request) string

Types

type Cache

type Cache interface {
	Get(ctx context.Context, url string) (response []byte, insertion *time.Time, err error)
	Set(ctx context.Context, url string, response []byte, expiration time.Duration) error
}

type CachedRoundTripper

type CachedRoundTripper struct {
	// contains filtered or unexported fields
}

func Wrap

func Wrap(delegate http.RoundTripper, cache Cache, opts ...Option) *CachedRoundTripper

func WrapWithClock

func WrapWithClock(delegate http.RoundTripper, cache Cache, now func() time.Time, opts ...Option) *CachedRoundTripper

func (*CachedRoundTripper) RoundTrip

func (c *CachedRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

type EventListener

type EventListener interface {
	Miss(req *http.Request)
	Hit(req *http.Request)
}

type KeyFunc

type KeyFunc func(r *http.Request) string

type Option

type Option func(*requestOption)

func DefaultExpirationOption

func DefaultExpirationOption(expiration time.Duration) Option

func KeyFuncOption

func KeyFuncOption(kf KeyFunc) Option

func ListenerOption

func ListenerOption(l EventListener) Option

Jump to

Keyboard shortcuts

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