modules

package
v0.0.0-...-1056671 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache(r Repository, s KeyValueStore, f FileStorage, l Logger) *Cache

func (*Cache) ListVersions

func (c *Cache) ListVersions(ctx context.Context, owner, repo, module string) ([]string, error)

func (*Cache) ProxyDownload

func (c *Cache) ProxyDownload(ctx context.Context, owner, repo, module, version string, w io.Writer) error

type Cipher

type Cipher interface {
	Seal(dst, nonce, plaintext, additionalData []byte) []byte
	Open(dst, nonce, ciphertext, additionalData []byte) ([]byte, error)
	NonceSize() int
}

type Config

type Config struct {
	ProxySecret     []byte        `envconfig:"PROXY_SECRET" required:"true"`
	TokenExpiration time.Duration `envconfig:"TOKEN_EXPIRATION" default:"60s"`
}

type FileStorage

type FileStorage interface {
	Open(filename string) (io.ReadCloser, error)
	Create(filename string) (io.WriteCloser, error)
}

type Handler

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

func NewHTTP

func NewHTTP(cfg Config, log Logger, r Repository) (*Handler, error)

func (*Handler) DownloadURL

func (h *Handler) DownloadURL(w http.ResponseWriter, r *http.Request)

func (*Handler) ListVersions

func (h *Handler) ListVersions(w http.ResponseWriter, r *http.Request)

func (*Handler) ProxyDownload

func (h *Handler) ProxyDownload(w http.ResponseWriter, r *http.Request)

type KeyValueStore

type KeyValueStore interface {
	Get(key string) ([]string, bool)
	Set(key string, value []string, d ...time.Duration)
}

type Logger

type Logger interface {
	Error(msg string, args ...any)
	Info(msg string, args ...any)
}

type Repository

type Repository interface {
	ListVersions(ctx context.Context, owner, repo, module string) ([]string, error)
	ProxyDownload(ctx context.Context, owner, repo, module, version string, w io.Writer) error
}

type StoreInPath

type StoreInPath string

StoreInPath implements the FileStorage interface by storing files locally on the file-system at the specified path. It's a bare minimum implementation, and doesn't create any folders.

func (StoreInPath) Create

func (s StoreInPath) Create(filename string) (io.WriteCloser, error)

func (StoreInPath) Open

func (s StoreInPath) Open(filename string) (io.ReadCloser, error)

Jump to

Keyboard shortcuts

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