repo

package
v0.12.5 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: BSD-2-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlobRead   = 'R' // A blob has been read
	BlobWrite  = 'W' // A blob has been written
	BlobDelete = 'D' // A blob has been deleted
)

Define all valid operations.

View Source
const DefaultDirMode os.FileMode = 0700

DefaultDirMode is the file mode used for directory creation if not overridden in the Options

View Source
const DefaultFileMode os.FileMode = 0600

DefaultFileMode is the file mode used for file creation if not overridden in the Options

Variables

View Source
var BlobPathRE = regexp.MustCompile(`^/(data|index|keys|locks|snapshots)/([0-9a-f]{64})?$`)

BlobPathRE matches valid blob URI paths with optional object IDs

View Source
var FileTypes = []string{"config"}

FileTypes are files stored directly under the repo direct that are accessible through a request

View Source
var ObjectTypes = []string{"data", "index", "keys", "locks", "snapshots"}

ObjectTypes are subdirs that are used for object storage

Functions

This section is empty.

Types

type Blob

type Blob struct {
	Name string `json:"name"`
	Size int64  `json:"size"`
}

Blob represents a single blob, its name and its size.

type BlobMetricFunc

type BlobMetricFunc func(objectType string, operation BlobOperation, nBytes uint64)

BlobMetricFunc is the callback signature for blob metrics. Such a callback can be passed in the Options to keep track of various metrics. objectType: one of ObjectTypes operation: one of the BlobOperations above nBytes: the number of bytes affected, or 0 if not relevant TODO: Perhaps add http.Request for the username so that this can be cached?

type BlobOperation

type BlobOperation byte

BlobOperation describe the current blob operation in the BlobMetricFunc callback.

type Handler

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

Handler handles all REST API requests for a single Restic backup repo Spec: https://restic.readthedocs.io/en/latest/100_references.html#rest-backend

func New

func New(path string, opt Options) (*Handler, error)

New creates a new Handler for a single Restic backup repo. path is the full filesystem path to this repo directory. opt is a set of options.

func (*Handler) ServeHTTP

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

ServeHTTP performs strict matching on the repo part of the URL path and dispatches the request to the appropriate handler.

type Options

type Options struct {
	AppendOnly     bool // if set, delete actions are not allowed
	Debug          bool
	DirMode        os.FileMode
	FileMode       os.FileMode
	NoVerifyUpload bool

	// If set, we will panic when an internal server error happens. This
	// makes it easier to debug such errors.
	PanicOnError bool

	BlobMetricFunc BlobMetricFunc
	QuotaManager   *quota.Manager
}

Options are options for the Handler accepted by New

Jump to

Keyboard shortcuts

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