snowdrift

package module
v0.0.0-...-c2c7da8 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2014 License: BSD-3-Clause Imports: 15 Imported by: 0

README

Snowdrift

Snowdrift is a URL shortener written in Go. Take a look at the example.

Snowdrift shortening

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCodeExists = errors.New("snowdrift: code already exists")
View Source
var ErrNotFound = errors.New("snowdrift: not found")
View Source
var ErrURLExists = errors.New("snowdrift: url already exists")

Functions

func New

func New(c *Config) *martini.Martini

Types

type Backend

type Backend interface {
	Add(url, digest, code string) error
	GetCode(digest string) (string, error)
	GetURL(code string) (string, error)
	NextID(obscure bool) (int, error)
}

func NewMemoryBackend

func NewMemoryBackend() Backend

func NewRedisBackend

func NewRedisBackend(conn redis.Conn, prefix string) Backend

func NewRiakBackend

func NewRiakBackend(client *riak.Client, prefix string, idb IDBackend) Backend

type Config

type Config struct {
	Backend        Backend
	HashSalt       string
	URLPrefix      string
	RootRedirect   string
	AllowedOrigins *regexp.Regexp
	ReportErr      func(err error, req *http.Request)
}

type IDBackend

type IDBackend interface {
	NextID(obscure bool) (int, error)
}

type MemoryBackend

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

func (*MemoryBackend) Add

func (b *MemoryBackend) Add(url, digest, code string) error

func (*MemoryBackend) GetCode

func (b *MemoryBackend) GetCode(digest string) (string, error)

func (*MemoryBackend) GetURL

func (b *MemoryBackend) GetURL(code string) (string, error)

func (*MemoryBackend) NextID

func (b *MemoryBackend) NextID(obscure bool) (int, error)

type RedisBackend

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

func (*RedisBackend) Add

func (b *RedisBackend) Add(url, digest, code string) error

func (*RedisBackend) GetCode

func (b *RedisBackend) GetCode(digest string) (string, error)

func (*RedisBackend) GetURL

func (b *RedisBackend) GetURL(code string) (string, error)

func (*RedisBackend) NextID

func (b *RedisBackend) NextID(obscure bool) (int, error)

type RiakBackend

type RiakBackend struct {
	IDBackend
	// contains filtered or unexported fields
}

func (*RiakBackend) Add

func (b *RiakBackend) Add(url, digest, code string) error

func (*RiakBackend) GetCode

func (b *RiakBackend) GetCode(digest string) (string, error)

func (*RiakBackend) GetURL

func (b *RiakBackend) GetURL(code string) (string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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