short

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// opCreate represents a create operation for short link
	OpCreate Op = "create"
	// opDelete represents a delete operation for short link
	OpDelete = "delete"
	// opUpdate represents a update operation for short link
	OpUpdate = "update"
	// opFetch represents a fetch operation for short link
	OpFetch = "fetch"
)

Variables

View Source
var (
	Validity        = regexp.MustCompile(`^[\w\-][\w\-. \/]+$`)
	ErrInvalidAlias = errors.New("invalid alias pattern")
)

Functions

func Cmd

func Cmd(ctx context.Context, operate Op, r *models.Redir) (err error)

Cmd processes the given alias and link with a specified op.

func DumpFile

func DumpFile(fname string)

DumpFile dumps the redir data into a given file in YAML format.

func Edit

func Edit(ctx context.Context, s *db.Store, operate Op, a string, r *models.Redir) (err error)

Edit edits the datastore for a given alias in a given operation. if the operation is create, then the alias is not necessary. if the operation is update/fetch/delete, then the alias is used to match the existing aliases, meaning that alias can be changed.

func ImportFile

func ImportFile(fname string)

ImportFile parses and imports the given file into redir database.

Types

type Op

type Op string

Op is a short link operator

func (Op) Valid

func (o Op) Valid() bool

Valid checks if the given Op is valid.

Jump to

Keyboard shortcuts

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