app

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version   = "devel"
	Commit    = "devel"
	BuildTime = "devel"
)
View Source
var ErrInvalidToken = errors.New("invalid token")
View Source
var ErrInvalidUrl = errors.New("invalid url")
View Source
var ErrNotFound = errors.New("not found")

Functions

This section is empty.

Types

type App

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

func NewApp

func NewApp(store LinkStore, tokenizer Tokenizer) *App

func (App) Close

func (a App) Close(ctx context.Context) errs.Error

func (App) CreateToken

func (a App) CreateToken(ctx context.Context, targetUrl string, expiredAt *time.Time) (key string, added bool, err errs.Error)
func (a App) DeleteLink(ctx context.Context, key string) errs.Error
func (a App) GetLink(ctx context.Context, key string) (*Link, errs.Error)
func (a App) HitLink(ctx context.Context, key string) (*Link, errs.Error)
type Link struct {
	Id        int
	Key       string
	TargetUrl string
	CreatedAt time.Time
	ExpiredAt *time.Time
	DeletedAt *time.Time
	Hits      int
}

type LinkStore

type LinkStore interface {
	Create(ctx context.Context, targetUrl string, expiredAt *time.Time) (int, bool, errs.Error)
	Get(ctx context.Context, id int) (*Link, errs.Error)
	Hit(ctx context.Context, id int) (*Link, errs.Error)
	SetDeleted(ctx context.Context, id int) errs.Error
	Delete(ctx context.Context, id int) errs.Error
	Close(ctx context.Context) errs.Error
}

type Tokenizer

type Tokenizer interface {
	Decode(key string) (int, error)
	Encode(id int) (string, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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