Documentation ¶
Overview ¶
Package proxy implements a HTTP caching proxy for Node package registry (NPM). See https://github.com/pkgems/npm-cache-proxy/ for more information about proxy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database interface { Get(key string) (string, error) Set(key string, value string, ttl time.Duration) error Delete(key string) error Keys(prefix string) ([]string, error) Health() error }
Database provides interface for data storage.
type DatabaseRedis ¶
DatabaseRedis implements Database interface for Redis database.
func (DatabaseRedis) Delete ¶
func (db DatabaseRedis) Delete(key string) error
Delete deletes data by key.
func (DatabaseRedis) Get ¶
func (db DatabaseRedis) Get(key string) (string, error)
Get returns data by key.
func (DatabaseRedis) Health ¶
func (db DatabaseRedis) Health() error
Health returns an error if database connection cannot be estabilished.
type Options ¶
type Options struct { DatabasePrefix string DatabaseExpiration time.Duration UpstreamAddress string }
Options provides dynamic options for Proxy. This can be used for namespace separation, allowing multiple users use the same proxy instance simultaneously.
type Proxy ¶
Proxy is the proxy instance, it contains Database and HttpClient as static options and GetOptions as dynamic options provider
func (Proxy) GetCachedPath ¶
func (proxy Proxy) GetCachedPath(options Options, path string, request *http.Request) ([]byte, error)
GetCachedPath returns cached upstream response for a given url path.
func (Proxy) ListCachedPaths ¶
ListCachedPaths returns list of all cached url paths.
func (Proxy) PurgeCachedPaths ¶
PurgeCachedPaths deletes all cached url paths.