Documentation ¶
Overview ¶
Package storages allows multiple implementation on how to store URLs as shorter names and retrieve them later.
There are currently two types of storage layers, Named and Unnamed. Named storage layers allow the user to provide a short name and a URL Unnamed storage layers only accept the URL to store
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrURLEmpty = errors.New("provided URL is of zero length") ErrShortEmpty = errors.New("provided short name is of zero length") ErrURLNotAbsolute = errors.New("provided URL is not an absolute URL") ErrShortNotSet = errors.New("storage layer doens't have a URL for that short code") ErrShortExhaustion = errors.New("tried to set short, but unable to find a unique shortname within 10 tries") )
View Source
var SupportedStorageTypes = make(map[string]interface{})
Functions ¶
func FlattenPath ¶
Takes a possibly multilevel path and flattens it by dropping any slashes
Types ¶
type Filesystem ¶
type Filesystem struct { Root string // contains filtered or unexported fields }
func NewFilesystem ¶
func NewFilesystem(root string) (*Filesystem, error)
func (*Filesystem) Code ¶
func (s *Filesystem) Code(url string) string
func (*Filesystem) SaveName ¶
func (s *Filesystem) SaveName(rawShort, url string) error
type Inmem ¶
type Inmem struct { RandLength int // contains filtered or unexported fields }
func NewInmemFromMap ¶
type NamedStorage ¶
Click to show internal directories.
Click to hide internal directories.