common

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DateLayout is standard yyyy-mm-dd format
	DateLayout = "2006-01-02 15:04:05"

	// ShortCodeLength is length of short code to be generated (5-12 chars)
	ShortCodeLength = 6

	// PopularHits is the number of hits required to mark a short code as popular
	PopularHits = 5
)

Variables

View Source
var (
	ErrInvalidURL      = errors.New("url is invalid")
	ErrInvalidURLLen   = errors.New("url is too short or too long, should be 15-2048 chars")
	ErrFilteredURL     = errors.New("url matches filter pattern")
	ErrKeywordsCount   = errors.New("keywords must not be more than 10")
	ErrKeywordLength   = errors.New("keyword must contain 2-25 characters")
	ErrInvalidKeyword  = errors.New("keyword must be alphanumeric (dash/underscore allowed)")
	ErrInvalidDate     = errors.New("expires_on should be in 'yyyy-mm-dd hh:mm:ss' format")
	ErrPastExpiration  = errors.New("expires_on can not be date in past")
	ErrURLAlreadyShort = errors.New("url is already shortened")
	ErrNoMatchingData  = errors.New("no data matching given criteria")
	ErrTokenRequired   = errors.New("auth token is required")
	ErrTokenInvalid    = errors.New("auth token is invalid")
	ErrShortCodeEmpty  = errors.New("short_code must not be empty")
	ErrNoShortCode     = errors.New("short_code is not found")
	ErrServerError     = errors.New("unexpected error encountered in server side")
)

Common errors

View Source
var ShortCodeRegex, _ = regexp.Compile("^[a-zA-Z0-9]{4,12}$")

ShortCodeRegex is regex to check if a string looks like short code

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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