shortlink

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package shortlink resolves slugs to targets, records click events asynchronously, and renders the password gate when a link is protected.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service handles redirect resolution and analytics.

func New

func New(db *gorm.DB, g *geo.Resolver) *Service

func (*Service) Handle

func (s *Service) Handle(w http.ResponseWriter, r *http.Request, link *models.Link)

Handle serves a redirect (or the password gate) and records the click. An expired/over-limit link redirects to its ExpiredURL when set, else 404s.

func (*Service) Lookup

func (s *Service) Lookup(host, slug string) (*models.Link, bool)

Lookup finds an enabled, non-archived link for (host, slug), preferring an exact host match and falling back to a host-agnostic link. Expiry and click limits are evaluated in Handle so an expired link can still honor ExpiredURL.

Jump to

Keyboard shortcuts

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