feat(statuspage): serve public status pages from api snapshots

Pages render without JavaScript, are matched by verified custom domain
or by slug, and stay available from a stale snapshot for ten minutes if
the API is unreachable. Snapshots contain no targets or error details.

Refs #21, #22

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 08:39:00 +01:00
1 parent d820547e8c
commit 2b72715a9d
8 files changed
+1017

No files matched your search

+7
View File
@@ -14,7 +14,9 @@ import (
"git.zb-server.de/ZB-Server/uptimesebi/internal/agentapi"
"git.zb-server.de/ZB-Server/uptimesebi/internal/buildinfo"
"git.zb-server.de/ZB-Server/uptimesebi/internal/config"
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
"git.zb-server.de/ZB-Server/uptimesebi/internal/platform"
"git.zb-server.de/ZB-Server/uptimesebi/internal/statuspage"
"git.zb-server.de/ZB-Server/uptimesebi/internal/web"
)
@@ -49,12 +51,17 @@ func run(log *slog.Logger, level *slog.LevelVar) error {
return fmt.Errorf("token belongs to a %s agent, not a status page server", hello.Kind)
}
catalog, err := i18n.Load()
if err != nil {
return err
}
health := platform.NewHealth(map[string]platform.Probe{
"api": func(ctx context.Context) error { _, err := client.Hello(ctx); return err },
})
r := platform.NewRouter(log)
health.Register(r)
r.StaticFS("/static", web.Static())
statuspage.New(client, catalog, log, cfg.Hosts).Mount(r)
return platform.Serve(ctx, log, platform.NewHTTPServer(cfg.Listen, r), health, 5*time.Second, cfg.ShutdownTimeout)
}