37cfa090ac
- GET /api/health endpoint returning Docker connectivity status - Sidebar shows Docker connection dot (green=connected, red=disconnected) - Stale scanner returns store-only results when Docker is unavailable - Polls health every 30s
26 lines
494 B
Go
26 lines
494 B
Go
package api
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
// getHealth handles GET /api/health.
|
|
// Returns connectivity status for Docker and other services.
|
|
func (s *Server) getHealth(w http.ResponseWriter, r *http.Request) {
|
|
ctx, cancel := context.WithTimeout(r.Context(), 5*time.Second)
|
|
defer cancel()
|
|
|
|
dockerOK := false
|
|
if s.docker != nil {
|
|
if err := s.docker.Ping(ctx); err == nil {
|
|
dockerOK = true
|
|
}
|
|
}
|
|
|
|
respondJSON(w, http.StatusOK, map[string]any{
|
|
"docker": dockerOK,
|
|
})
|
|
}
|