-
Notifications
You must be signed in to change notification settings - Fork 6
/
proxy.go
35 lines (31 loc) · 945 Bytes
/
proxy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
// Package proxy implements a HTTP caching proxy for Node package registry (NPM).
// See https://github.com/emeralt/npm-cache-proxy/ for more information about proxy.
//
package proxy
import (
"net/http"
"time"
)
// Proxy is the proxy instance, it contains Database and HttpClient as static options
// and GetOptions as dynamic options provider
type Proxy struct {
Database Database
HttpClient *http.Client
}
// Options provides dynamic options for Proxy.
// This can be used for namespace separation,
// allowing multiple users use the same proxy instance simultaneously.
type Options struct {
DatabasePrefix string
DatabaseExpiration time.Duration
UpstreamAddress string
}
// Database provides interface for data storage.
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
}