Documentation
¶
Overview ¶
Package api is the composition root's one dependency: an http.Handler satisfying api/openapi.yaml, serving the aggregated dashboard snapshot and the static frontend. It lives under internal/ because the API this service offers is its endpoints, not its Go packages — see go.md's "a server keeps everything in internal/ and its commands in cmd/".
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMux ¶
NewMux wires the handlers registered against api/openapi.yaml: liveness, passkey registration/login/session, per-user settings, the aggregated dashboard snapshot, and the static frontend that consumes it.
The dashboard itself, and the page that renders it, require a valid session; registration, login and the handful of static assets a login page needs (its own HTML/JS, the shared stylesheet, the favicon) don't.
Types ¶
type AdminUser ¶ added in v0.9.0
type AdminUser struct {
Username string `json:"username"`
DisplayName string `json:"displayName"`
IsAdmin bool `json:"isAdmin"`
CreatedAt string `json:"createdAt"`
}
AdminUser matches components.schemas.AdminUser in api/openapi.yaml.
type Deps ¶ added in v0.8.0
type Deps struct {
AuthService *auth.Service
AuthStore *auth.Store
SettingsStore *settings.Store
// Manager holds each signed-in user's own Aggregator, built from
// their saved Credentials via BuildSources.
Manager *dashboard.Manager
BuildSources func(settings.Credentials) []dashboard.Source
// AppContext is the process's own long-lived context (canceled on
// shutdown), not any one request's — a handler that starts a
// Manager-owned background refresh goroutine has to root it here, not
// in the *http.Request context that dies the moment that handler
// returns.
AppContext context.Context
}
Deps is everything NewMux needs — passed as one struct rather than a long parameter list, since it's grown one dependency per feature slice (auth, then per-user settings) and reads better named than positional.
type Health ¶
type Health struct {
Status string `json:"status"`
}
Health matches components.schemas.Health in api/openapi.yaml.
type SessionUser ¶ added in v0.7.0
type SessionUser struct {
Username string `json:"username"`
DisplayName string `json:"displayName"`
IsAdmin bool `json:"isAdmin"`
}
SessionUser matches components.schemas.SessionUser in api/openapi.yaml.
type SettingsResponse ¶ added in v0.8.0
type SettingsResponse struct {
GitHubUsername string `json:"githubUsername"`
GitHubTokenSet bool `json:"githubTokenSet"`
ForgejoURL string `json:"forgejoUrl"`
ForgejoUsername string `json:"forgejoUsername"`
ForgejoTokenSet bool `json:"forgejoTokenSet"`
}
SettingsResponse matches components.schemas.SettingsResponse in api/openapi.yaml. Tokens are never sent back to the browser once saved — *Set reports whether one is on file, not what it is.