app

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 15 Imported by: 0

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

func OpsHandler(readDB *sql.DB, version string) http.Handler

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.

func (*App) Routes

func (a *App) Routes() http.Handler

Routes registers every route and wraps the mux in the standard middleware chain.

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.

Jump to

Keyboard shortcuts

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