models

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_ORIGIN_LINK_LENGTH = 255
	MIN_ORIGIN_LINK_LENGTH = 0
)
View Source
const (
	STATUS_ACTIVE  = "active"
	STATUS_EXPIRED = "expired"
	STATUS_DELETED = "deleted"
)
View Source
const (
	MAX_ROLE_LENGHT  = 10
	MAX_TOKEN_LENGHT = 64

	ROLE_ADMIN  = "admin"
	ROLE_USER   = "user"
	ROLE_BANNED = "banned"
)

Variables

View Source
var (
	RoleLengthErr  = errors.New("role name too long (max length: 10)")
	TokenLengthErr = errors.New("token too long (max length: 64)")
)
View Source
var (
	OriginLinkLengthErr = errors.New("Origin link too long or too short (max length 255 characters, min length 0 characters)")
)

Functions

func CreateToken

func CreateToken(length int) string
func GenerateShortLink(length int) string

func IsValidURL

func IsValidURL(url string) bool

Types

type Link struct {
	UID                   int    `json:"uid"`
	OriginLink            string `json:"origin_link"`
	ShortLink             string `json:"short_link"`
	CreateTime            int64  `json:"create_time"`
	ExpireTime            int64  `json:"expire_time"`
	Status                string `json:"status"`
	ScheduledDeletionTime int64  `json:"scheduled_deletion_time"`
}

func (*Link) Validate

func (l *Link) Validate() error

type User

type User struct {
	UID   int    `json:"uid"`
	Token string `json:"token"`
	Role  string `json:"role"`
}

func (*User) Validate

func (u *User) Validate() error

Jump to

Keyboard shortcuts

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