shortify

package module
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoPrefixes = errors.New("no more prefixes available")
)
View Source
var ErrNotFound = errors.New("short URL not found")

Functions

func GetUnixListener

func GetUnixListener(path string) (net.Listener, error)

util

Types

type Config

type Config struct {
	DataFolder string
}

type PrefixManager

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

func NewPrefixManager

func NewPrefixManager(db *bolt.DB) (*PrefixManager, error)

func (*PrefixManager) AllocateNewPrefix

func (pm *PrefixManager) AllocateNewPrefix() (uint16, error)

AllocateNewPrefix assigns next prefix > 0

type Server

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

func New

func New(cfg Config) (*Server, error)

func (*Server) Admin

func (s *Server) Admin() *fiber.App

func (*Server) GetURL

func (s *Server) GetURL(id string) (string, error)

GetURL first checks cache, then DB, and updates cache on hit

func (*Server) HandleGetURL

func (s *Server) HandleGetURL() func(*fiber.Ctx) error

func (*Server) HandlePostURL

func (s *Server) HandlePostURL() func(*fiber.Ctx) error

func (*Server) LogVisit

func (s *Server) LogVisit(log VisitLog)

type Storage

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

func NewStorage

func NewStorage(db *bolt.DB) (*Storage, error)

func (*Storage) Get

func (s *Storage) Get(id string) (string, error)

func (*Storage) Put

func (s *Storage) Put(id, url string) error

type VisitLog

type VisitLog struct {
	ShortID string
	LongURL string

	IP string

	UserAgent string
	Referer   string
	Language  string

	Time time.Time
}

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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