shared

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoEntryFound = errors.New("no entry found with this ID")

ErrNoEntryFound is returned when no entry to a id is found

Functions

This section is empty.

Types

type Entry

type Entry struct {
	// RemoteAddr is the clients address
	ID                    string     `json:"id"`
	URL                   string     `json:"url"`
	RemoteAddr            string     `json:",omitempty"`
	DeletionURL           string     `json:",omitempty"`
	Password              []byte     `json:",omitempty"`
	LastVisit, Expiration *time.Time `json:",omitempty"`
	CreatedOn             *time.Time `json:"-"`
	VisitCount            int
}

Entry is the data set which is stored in the DB as JSON

type Storage

type Storage interface {
	GetEntryByID(string) (*Entry, error)
	GetVisitors(string) ([]Visitor, error)
	DeleteEntry(string) error
	IncreaseVisitCounter(*Entry) error
	CreateEntry(Entry, string) (*Entry, error)
	CreateUser(models.User) (*models.User, error)
	FindUserByEmail(string) (*models.User, error)
	FindUserByToken(token string) (*models.User, error)
	LinksList() ([]*Entry, error)
	LinkUpdate(*Entry) (*Entry, error)
	UserUpdateToken(id uint, token string) error
	Close() error

	// stats
	ListStats() (*int, *int, error)
}

Storage is an interface which will be implmented by each storage e.g. bolt, sqlite

type Visitor

type Visitor struct {
	IP, Referer, UserAgent                                 string
	Timestamp                                              time.Time
	UTMSource, UTMMedium, UTMCampaign, UTMContent, UTMTerm string `json:",omitempty"`
}

Visitor is the entry which is stored in the visitors bucket

Jump to

Keyboard shortcuts

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