app

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 29 Imported by: 1 module, 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 main of a generated Surface binary: it starts Substrate (config, logging, health, the HTTP host, the database), hands the core what Substrate opened, and serves. A generated main.go is one call to Main.

Substrate supplies the mechanism; Surface is the app on top of it. The app's own settings are not Substrate config: they live in the app's database and change live (see the core). Substrate's config holds only what must be known before the database opens: the listen address, the log level, the database path.

Index

Constants

View Source
const AuthIdentity = "identity"

AuthIdentity is the Config.Auth value that turns sign-in on.

Variables

This section is empty.

Functions

func DataDir

func DataDir(app string, getenv func(string) string) (string, error)

DataDir is where the app keeps its data: <APP>_DATA_DIR, or the app's directory under XDG_DATA_HOME (default ~/.local/share).

func Main

func Main(cfg Config)

Main runs the app until it is interrupted, and exits non-zero on failure.

func Run

func Run(ctx context.Context, cfg Config, getenv func(string) string, args []string) error

Run starts Substrate and runs the command line.

Types

type Config

type Config struct {
	// Name is the app's name; Title is how a person reads it.
	Name  string
	Title string
	// Modules are the Surface modules to start, in order (surface_wiring.go).
	Modules []string
	// SubstrateModules and SubstrateConfigJSON come from substrate_wiring.go.
	SubstrateModules    []string
	SubstrateConfigJSON string
	// Assets is the built page, or nil.
	Assets fs.FS
	// Ready, when set, learns the bound address (tests listen on port 0).
	Ready func(net.Addr)
	// Auth is "" (or "off": one owner, loopback only, no sign-in) or AuthIdentity: people
	// sign in through Substrate's identity module (app/auth.go). surface.yaml's auth sets it.
	Auth string
}

Config is what the generated wiring gives Main.

Jump to

Keyboard shortcuts

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