package server import ( "net/http" "time" "github.com/indifferentketchup/llama-sidecar/internal/config" "github.com/indifferentketchup/llama-sidecar/internal/pool" ) func healthHandler(p *pool.Pool, cfg *config.Config, startedAt time.Time) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { sidecars := p.List() writeJSON(w, http.StatusOK, map[string]any{ "status": "ok", "sidecars": len(sidecars), "max": cfg.MaxSidecars, "uptime_seconds": int(time.Since(startedAt).Seconds()), }) } } func listSidecarsHandler(p *pool.Pool) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusOK, p.List()) } } func deleteSidecarHandler(p *pool.Pool) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { hash := r.PathValue("hash") if hash == "" { writeJSON(w, http.StatusBadRequest, map[string]string{"error": "hash required"}) return } if err := p.Remove(hash); err != nil { writeJSON(w, http.StatusNotFound, map[string]string{"error": err.Error()}) return } writeJSON(w, http.StatusOK, map[string]string{"status": "removed"}) } }