Documentation
¶
Overview ¶
Package app is the HTTP edge: routing, middleware, handlers, rendering.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OpsHandler ¶
OpsHandler serves /healthz and /debug/pprof on the localhost ops listener. The health ping uses the read pool: a ping queued behind the write pool's single connection times out during any long write — a healthy app flapping 503.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
func New ¶
func New(logger *slog.Logger, games GameStore, templatesFS, staticFS fs.FS, version string) (*App, error)
New parses the page templates once, failing the boot on any error. version is the asset cache-buster: it reaches the pages as a template function, so no handler has to carry it in its view data.
type GameStore ¶
type GameStore interface {
Create(ctx context.Context, g *domain.Game) error
Get(ctx context.Context, id string) (*domain.Game, error)
Update(ctx context.Context, id string, change func(*domain.Game) error) (*domain.Game, error)
}
GameStore is what the app needs from persistence (consumer-defined). Update takes the change as a function so the store can load, apply, and save inside one transaction — the game rules stay in the domain either way.