golink

package module
v0.0.0-...-db44bb4 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: BSD-3-Clause Imports: 27 Imported by: 0

README

The golink server runs http://go/, a private shortlink service for tailnets.

Documentation

Overview

The golink server runs http://go/, a private shortlink service for tailnets.

Index

Constants

This section is empty.

Variables

View Source
var LastSnapshot []byte

LastSnapshot is the data snapshot (as returned by the /.export handler) that will be loaded on startup.

Functions

func Run

func Run() error

Types

type ClickStats

type ClickStats map[string]int

ClickStats is the number of clicks a set of links have received in a given time period. It is keyed by link short name, with values of total clicks.

type Link struct {
	Short    string // the "foo" part of http://go/foo
	Long     string // the target URL or text/template pattern to run
	Created  time.Time
	LastEdit time.Time // when the link was last edited
	Owner    string    // user@domain
	Clicks   int       `json:",omitempty"` // number of times this link has been served
}

Link is the structure stored for each go short link.

type SQLiteDB

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

SQLiteDB stores Links in a SQLite database.

func NewSQLiteDB

func NewSQLiteDB(f string) (*SQLiteDB, error)

NewSQLiteDB returns a new SQLiteDB that stores links in a SQLite database stored at f.

func (*SQLiteDB) Load

func (s *SQLiteDB) Load(short string) (*Link, error)

Load returns a Link by its short name.

It returns fs.ErrNotExist if the link does not exist.

The caller owns the returned value.

func (*SQLiteDB) LoadAll

func (s *SQLiteDB) LoadAll() ([]*Link, error)

LoadAll returns all stored Links.

The caller owns the returned values.

func (*SQLiteDB) LoadStats

func (s *SQLiteDB) LoadStats() (ClickStats, error)

LoadStats returns click stats for links.

func (*SQLiteDB) Save

func (s *SQLiteDB) Save(link *Link) error

Save saves a Link.

func (*SQLiteDB) SaveStats

func (s *SQLiteDB) SaveStats(stats ClickStats) error

SaveStats records click stats for links. The provided map includes incremental clicks that have occurred since the last time SaveStats was called.

Directories

Path Synopsis
cmd
golink
The golink server runs http://go/, a private shortlink service for tailnets.
The golink server runs http://go/, a private shortlink service for tailnets.

Jump to

Keyboard shortcuts

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