client

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package client provides an http client used extensively by Takeout for syncing media. There's support for local file-based caching and cache-only usage.

Index

Constants

View Source
const (
	DirectiveMaxAge       = "max-age"
	DirectiveOnlyIfCached = "only-if-cached"
)

Variables

View Source
var (
	ErrCacheMiss          = errors.New("cache miss")
	ErrSchemeNotSupported = errors.New("scheme not supported")
)

Functions

func Get added in v0.14.0

func Get(path string) ([]byte, error)

Types

type Config

type Config struct {
	UserAgent string
	CacheDir  string
	MaxAge    time.Duration
}

func (*Config) Merge

func (c *Config) Merge(o Config)

type Getter

type Getter interface {
	Get(url string) (http.Header, []byte, error)
	GetBody(url string) ([]byte, error)
	GetJson(url string, result interface{}) error
	GetJsonWith(headers map[string]string, url string, result interface{}) error
	GetXML(url string, result interface{}) error
	GetPLS(url string) (pls.Playlist, error)
}

func NewCacheOnlyGetter

func NewCacheOnlyGetter(config Config) Getter

func NewDefaultGetter added in v0.14.0

func NewDefaultGetter() Getter

func NewGetter

func NewGetter(config Config) Getter

func NewTransportGetter added in v0.14.0

func NewTransportGetter(config Config, transport http.RoundTripper) Getter

type RateLimiter added in v0.14.0

type RateLimiter interface {
	RateLimit(host string)
}
var DefaultLimiter RateLimiter = &timeLimiter{}
var UnlimitedLimiter RateLimiter = unlimitedLimiter(0)

Jump to

Keyboard shortcuts

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