Documentation
¶
Overview ¶
Package storage provides an interface that can be used to connect to various ways that links can be stored and retrieved. It also stores common variables and parameters that are expected to be used across the store implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("input url not found") ErrStorageSetupFailed = errors.New("storage setup failed") ErrReadOnlyStorage = errors.New("storage is read only") ErrFailed = errors.New("storage implementation failed") ErrCorrupt = errors.New("the data returned by the storage is invalid") )
Err* are common errors that the storage implementations will return.
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
Authenticator is an extension to the storage interface that allows verifying whether a given user is the canonical owner of a given URL.
Expects to be supplied with a context with the agent stored at the appropriate key. Returns false in the case the user doesn't own the request, or the request cannot be authenticated (e.g. agent is missing)
type CtxKey ¶
type CtxKey string
CtxKey is a type designed to allow delimiting key/value pairs
const ( // CtxKeyAgent is the context address at which the owner will be found, if there is one. CtxKeyAgent CtxKey = "agent" )
type Storer ¶
type Storer interface { // Get a URL, given a supplied shortlink. Get(ctx context.Context, url *url.URL) (*url.URL, error) // Store a map between a shortlink and the destination. Put(ctx context.Context, from *url.URL, to *url.URL) error }
Storer is the interface that retrieves links supplied to it. Methods are named after the RESTful HTTP verbs, as the meanings are semantically similar.
Directories
¶
Path | Synopsis |
---|---|
Package boltdb implements storage based on the BoltDB database, backed by the filesystem.
|
Package boltdb implements storage based on the BoltDB database, backed by the filesystem. |
Package di provides a mechanism to select storage providers.
|
Package di provides a mechanism to select storage providers. |
Package firestore implements a storage layer with Google cloud firestore.
|
Package firestore implements a storage layer with Google cloud firestore. |
Package memory stores the entire data set in memory.
|
Package memory stores the entire data set in memory. |
Package test provides a storage implementation designed explicitly for testing
|
Package test provides a storage implementation designed explicitly for testing |
Package yaml provides a read only storage implementation which sources its URLs from a YAML file.
|
Package yaml provides a read only storage implementation which sources its URLs from a YAML file. |