web

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package web serves everything lfr shows to readers: each list's small site (latest issues, archive, feed, signup form), the confirm and unsubscribe pages, click and open tracking, MTA-STS policies and relay webhooks. There is no admin interface; operators use the CLI.

Index

Constants

This section is empty.

Variables

View Source
var ErrLimited = errors.New("too many signups")

ErrLimited is returned by Signup when a list sends too many confirmations.

View Source
var Pages = []string{"home", "archive", "issue", "message"}

Pages a site renders; each is its own template set.

Functions

func FromCloudflare

func FromCloudflare(remote string) bool

FromCloudflare reports whether a remote address ("ip:port") is a Cloudflare edge.

func Templates

func Templates() map[string]string

Templates are the built-in templates by file name, for editing on the machine where the agent works (lfr site <list> --eject).

Types

type Server

type Server struct {
	DB       *store.DB
	Lists    *lists.Service
	Issues   *issues.Service
	Renderer *issues.Renderer
	Tokens   *token.Signer
	Events   *events.Bus
	Config   config.Config
	Sites    *Sites
	Now      func() time.Time
	Log      *slog.Logger

	MailHost  func(ctx context.Context) string
	MTASTS    func(ctx context.Context, domain string) (string, bool) // policy text when lfr serves domain
	Signup    func(ctx context.Context, l *lists.List, email string, s lists.Signup) error
	Feedback  func(ctx context.Context, evs []feedback.Event)
	SNSClient *http.Client // fetches SNS certificates and confirms subscriptions
	// SNSTopic accepts the topic of a verified SNS message: the first one
	// confirmed is remembered, later ones must match it.
	SNSTopic func(ctx context.Context, arn string, confirm bool) bool
	// contains filtered or unexported fields
}

Server is the HTTP handler.

func (*Server) HookPath

func (s *Server) HookPath(provider string) string

HookPath is the secret webhook path relays post bounces and complaints to.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP routes by host, then path.

type Sites

type Sites struct {
	Dir string
	// contains filtered or unexported fields
}

Sites loads the templates of each list: the embedded defaults, with any file of the same name in <dir>/<list-slug>/ taking its place. custom.html there is added to every page (to redefine "style", for example), and email.html replaces the email layout. Edits are picked up within seconds.

func (*Sites) Asset

func (s *Sites) Asset(slug, name string) (string, bool)

Asset resolves a file under a list's assets directory, refusing paths that escape it.

func (*Sites) Check

func (s *Sites) Check(slug string) error

Check parses a list's templates and reports the first error.

func (*Sites) Email

func (s *Sites) Email(slug string) *template.Template

Email returns a list's custom email layout, or nil for the built-in one.

func (*Sites) Page

func (s *Sites) Page(slug, page string) (*template.Template, error)

Page returns the template set of a page for a list.

func (*Sites) Put

func (s *Sites) Put(slug string, files map[string][]byte) error

Put replaces a list's templates and assets with files (relative path → content). The new set must parse before it goes live, and it replaces the old one in a single rename, so readers never see a half-written site.

Jump to

Keyboard shortcuts

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