zlh-agent/internal/handlers/metrics.go
2026-03-07 20:59:27 +00:00

26 lines
551 B
Go

package handlers
import (
"net/http"
"zlh-agent/internal/metrics"
)
func HandleProcessMetrics(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
writeJSONError(w, http.StatusMethodNotAllowed, "GET only")
return
}
resp, stopped, err := metrics.ProcessMetrics()
if err != nil {
writeJSONError(w, http.StatusInternalServerError, err.Error())
return
}
if stopped {
writeJSON(w, http.StatusNotFound, map[string]any{"status": "stopped", "process": resp.Process})
return
}
writeJSON(w, http.StatusOK, resp)
}