publicurl

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package publicurl builds the absolute URLs that appear in emails and on public pages, so the code that writes them (sending, tracking, forms, reports) and the handlers that serve them agree on one layout:

/t/o/{token}                          open pixel (linktoken.Open)
/t/c/{token}                          click redirect (linktoken.Click)
/p/{workspace}/unsubscribe/{token}    unsubscribe page; POST is RFC 8058 one-click
/p/{workspace}/preferences/{token}    preference center
/p/{workspace}/confirm/{token}        double opt-in confirmation
/p/{workspace}/view/{token}           view an email in the browser
/p/{workspace}/subscribe[/{form}]     hosted subscribe page
/p/{workspace}/archive[/{issue}]      public newsletter archive
/p/{workspace}/archive.rss            archive feed
/r/{token}                            read-only shared campaign report

{workspace} is the workspace slug. Handlers must still check that a token's workspace matches the slug in the path.

Index

Constants

View Source
const (
	TrackingPrefix = "/t"
	PagesPrefix    = "/p"
	ReportPrefix   = "/r"
)

Path prefixes, for routers.

Variables

This section is empty.

Functions

func Effective

func Effective(saved, configured string) string

Effective is the instance's public URL: the address saved in the instance settings, else the server's http.public_url, without a trailing slash. Every reader of the setting goes through it, so they all agree.

Types

type Builder

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

Builder joins paths onto the instance's public URL.

func From

func From(src *Source) Builder

From returns a Builder that follows src.

func New

func New(publicURL string) Builder

New returns a Builder for a fixed public URL.

func (Builder) Archive

func (b Builder) Archive(workspace string) string

Archive is the public newsletter archive.

func (Builder) ArchiveFeed

func (b Builder) ArchiveFeed(workspace string) string

ArchiveFeed is the archive's RSS feed.

func (Builder) ArchiveIssue

func (b Builder) ArchiveIssue(workspace, issue string) string

ArchiveIssue is one issue in the public archive.

func (Builder) Base

func (b Builder) Base() string

Base returns the public URL without a trailing slash.

func (Builder) Click

func (b Builder) Click(token string) string

Click is the click redirect URL.

func (Builder) Confirm

func (b Builder) Confirm(workspace, token string) string

Confirm is the double opt-in confirmation link.

func (Builder) Honeypot

func (b Builder) Honeypot(token string) string

Honeypot is the hidden link of a tracked email: a person never sees it, so whatever follows it is a machine (review AN-2).

func (Builder) Open

func (b Builder) Open(token string) string

Open is the tracking pixel URL.

func (Builder) Preferences

func (b Builder) Preferences(workspace, token string) string

Preferences is the preference center.

func (Builder) Report

func (b Builder) Report(token string) string

Report is a read-only shared campaign report.

func (Builder) Subscribe

func (b Builder) Subscribe(workspace, form string) string

Subscribe is the hosted subscribe page; form is optional (the default form when empty).

func (Builder) Unsubscribe

func (b Builder) Unsubscribe(workspace, token string) string

Unsubscribe is the unsubscribe page; mail clients POST to the same URL for one-click unsubscribe (List-Unsubscribe-Post: List-Unsubscribe=One-Click).

func (Builder) ViewOnline

func (b Builder) ViewOnline(workspace, token string) string

ViewOnline shows an email in the browser.

type Source

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

Source is the instance's public URL as it is now: the server's http.public_url until an instance admin saves another one. Every Builder made from a Source follows its changes.

func NewSource

func NewSource(publicURL string) *Source

NewSource returns a Source set to publicURL.

func (*Source) Get

func (s *Source) Get() string

Get returns the public URL without a trailing slash.

func (*Source) Set

func (s *Source) Set(publicURL string) bool

Set changes the public URL and reports whether it changed.

Jump to

Keyboard shortcuts

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