agent: add system-info endpoint

This commit is contained in:
yusing
2025-02-10 12:34:08 +08:00
parent 9120bbea34
commit 73e2660e59
8 changed files with 151 additions and 18 deletions

View File

@@ -42,6 +42,7 @@ func NewHandler() http.Handler {
})
mux.HandleMethods("GET", agent.EndpointHealth, CheckHealth)
mux.HandleMethods("GET", agent.EndpointLogs, memlogger.LogsWS(nil))
mux.HandleMethods("GET", agent.EndpointSystemInfo, SystemInfo)
mux.ServeMux.HandleFunc("/", DockerSocketHandler())
return mux
}

View File

@@ -0,0 +1,17 @@
package handler
import (
"net/http"
"github.com/yusing/go-proxy/internal/api/v1/utils"
"github.com/yusing/go-proxy/internal/metrics"
)
func SystemInfo(w http.ResponseWriter, r *http.Request) {
info, err := metrics.GetSystemInfo(r.Context())
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
utils.RespondJSON(w, r, info)
}