app

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 60 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package app is the Lesstruct composition root: the shared platform — config, database, identity, content engine, media stack, plugin system, boot — that every edition wires its module list into. An edition is a fixed module list plus wiring; the concrete editions live in internal/editions/<name> (imported only by their thin mains) so a binary links only the modules its edition carries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(edition Edition)

Run boots an edition: loads config, wires the shared platform services, hands the edition its Wire and Mount hooks, runs migrations, and serves HTTP until shutdown.

Types

type Core added in v1.1.0

type Core struct {
	Cfg    *config.Config
	Logger *util.Logger

	// Database and module machinery.
	DB       *sql.DB
	Dialect  database.Dialect
	Registry *kernel.Registry

	// Registries and services shared by every edition.
	RoleService     *role.Service
	PostTypeService *posttype.Service
	PostTypeSlugs   []string
	ContentService  *contentdomain.Service
	MediaService    *mediadomain.Service
	MediaRepo       mediadomain.Repository
	AliasService    *aliasdomain.Service
	SEOService      *seodomain.Service
	UserRepo        repository.UserRepo
	ProfilePicture  appstorage.Storage
	EmailService    *email.Service

	// Effective flags. CommentsEnabled and RegistrationEnabled are refreshed
	// to their post-cascade values before Mount runs.
	CommentsEnabled     bool
	RegistrationEnabled bool
	HeadlessEnabled     bool
	Languages           []string
	PrimaryLanguage     string
	BaseURL             string

	// Legal resolution (round 6): the conventional documents the composition
	// root resolved once at boot, the explicit URL overrides, the navigation
	// placement, and the consent gates both the SSR engine and the commerce
	// modules enforce. A zero value keeps the pre-legal behavior. LegalNotice
	// selects the banner wording: the zero value renders the neutral pair
	// and the commerce edition adopts legal.StoreNoticeCopy.
	LegalResolution     legal.Resolution
	LegalOverrides      map[legal.Page]string
	LegalNav            legal.NavPlacement
	CheckoutConsent     bool
	RegistrationConsent bool
	LegalNotice         legal.NoticeCopy

	// PublicFieldRegistry gates /api/v1/public/* custom-field queries; a
	// closed registry fails every cf_*/sort_by request. IFrameHosts mirrors
	// the CSP frame-src allowlist for the HTML sanitizer.
	PublicFieldRegistry *config.PublicFieldRegistry
	IFrameHosts         []string

	// Platform handlers every edition serves.
	ContentHandler      *handlers.ContentHandler
	AgentContentHandler *agent.ContentHandler

	// Authorize gates capability-protected routes inside edition handlers
	// (the platform resolver over the role registry; unknown capabilities
	// and roles fail closed).
	Authorize kernel.CapabilityResolver

	// Candidates accumulates kernel modules in construction order: the
	// platform appends its always-present modules around the edition's Wire
	// hook so the default composition keeps its historical registration
	// order (the registry topologically sorts anyway — the order only pins
	// the init log and migration sequence).
	Candidates []kernel.Module

	// ThemeInstaller installs a ThemeProvider's embedded filesystem into the
	// SSR engine after InitAll. Editions without an SSR engine leave it nil
	// and the install loop is skipped; platform code never imports a theme
	// or the engine directly.
	ThemeInstaller func(fs.FS)
	// contains filtered or unexported fields
}

Core is the shared platform context an edition wires into: every service, repository, flag, and handler the composition root builds for all editions, plus the candidate list the edition appends its modules to. Edition-specific state (the SSR theme, the comments module, …) stays in the edition package — Core only carries types every binary links anyway.

func (*Core) Handlers added in v1.1.0

func (c *Core) Handlers() *HandlerSet

Handlers returns the edition-optional surface set. Editions fill the fields they carry; the rest stay nil and their routes unmount.

type Edition added in v1.1.0

type Edition struct {
	Name     string
	Comments bool
	Wire     func(*Core) error
	Mount    func(*Core) error
}

Edition is a fixed module list compiled into one binary: a curated slice of the first-party modules plus the wiring that mounts their handlers. The composition root (Run) builds the shared platform — config, database, identity, content engine, media stack, plugin system, boot — and hands the edition two hooks: Wire (construct edition services and modules, before the disabled-list cascade and InitAll) and Mount (build the handlers that depend on post-init state, after InitAll). Editions live in internal/editions/<name> as separate packages so a binary links only the modules its edition wires.

Comments declares whether the edition carries the comment system. The flag folds into commentsEnabled before the content service is built (the same pre-cascade value the default composition always used); the modules disabled cascade still applies on top at registration time.

type HandlerSet added in v1.1.0

type HandlerSet struct {
	SEO            routes.SEOSurface
	CommentBrowser routes.CommentBrowserHandler
	CommentAgent   routes.CommentAgentHandler
	WordPress      routes.WordPressSurface
	Hugo           routes.HugoSurface
	SSG            routes.SSGSurface
	Static         http.Handler
	AliasRedirect  *handlers.AliasRedirectHandler
	TextGen        routes.TextGenSurface
	Speech         routes.SpeechSurface

	// ConfigExtras contributes edition-specific keys to the public
	// GET /api/v1/config payload (e.g. the catalog block). Nil or empty
	// leaves the response unchanged.
	ConfigExtras func() map[string]any
}

HandlerSet holds the edition-optional HTTP surfaces. A nil field unmounts that surface's routes (routes.Setup nil-checks each one); an edition simply leaves the fields it does not carry at their zero values.

Jump to

Keyboard shortcuts

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