http: expose GET /api/version
This commit is contained in:
@@ -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,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user