Documentation
¶
Overview ¶
Package viewerhost fetches, verifies, caches, and serves the api-log-viewer single-page bundle at a local URL prefix.
The backend SOURCE pins (via Config wired by package config) both the viewer version and the expected SHA-256 of dist.zip. ensureCache will refuse to write anything that does not match the configured hash — the trust model is "GitHub release asset hash matches what the binary was compiled to expect, or we serve 503." There is no auto-update, no floating-latest, no fallback URL.
Operators can opt out (Enabled=false), point at a different repo or version (with a matching Sha256), or skip the fetch entirely by pointing LocalPath at an extracted dist tree (offline mode). If an operator overrides Repo or Version without supplying a matching Sha256, this package returns 503 with detail — the binary stays up so /api still serves.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Enabled bool // default true; if false, Handler always 503s
Repo string // e.g. "2nd1st/api-log-viewer"
Version string // tag, e.g. "v0.1.0"
Sha256 string // hex-encoded SHA-256 of dist.zip
CacheDir string // e.g. "<data_dir>/viewer-cache"
LocalPath string // if non-empty, skip fetch and serve from this dir
PublicPath string // URL prefix, e.g. "/viewer"
}
Config is the data shape Agent 3 will wire from internal/config. All fields are required when Enabled=true and LocalPath="".
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host is the runtime view of the viewer mount. Construct with New; query with Info; mount with Handler. It is safe for concurrent use — initState is set once during New, and the http.Handler returned by Handler is stateless beyond an immutable pointer back here.
func New ¶
New constructs a Host. It performs init (cache check / extract / local path stat) synchronously but never returns nil — on failure the Host reports source="error" via Info() and the Handler returns 503 with detail. Failures here do not bring down the binary.
type Info ¶
type Info struct {
Enabled bool `json:"enabled"`
Repo string `json:"repo,omitempty"`
Version string `json:"version,omitempty"`
Source string `json:"source"` // "cache" | "fetched" | "local" | "disabled" | "error"
Sha256 string `json:"sha256,omitempty"`
Error string `json:"error,omitempty"`
PublicPath string `json:"public_path,omitempty"`
}
Info is the snapshot reported via Host.Info() and embedded into /healthz output. JSON tags match what the README documents.