http: expose GET /api/version

This commit is contained in:
2026-05-06 21:39:13 +01:00
parent fe1ed49977
commit 22bcf69e6c
3 changed files with 63 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
package http
import (
"encoding/json"
stdhttp "net/http"
"gitea.dcglab.co.uk/steve/restic-manager/internal/version"
)
// handleVersion exposes the server's build-time identifying constants
// (set via -ldflags). Public-band — no secrets surface here, the agent
// updater compares its own agent_version byte-for-byte against the
// Version field to drive the "out of date" signal.
func (s *Server) handleVersion(w stdhttp.ResponseWriter, r *stdhttp.Request) {
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(map[string]string{
"version": version.Version,
"commit": version.Commit,
})
}