From af2faf3a26f49ed9472d8b76fbc45248234f2cf7 Mon Sep 17 00:00:00 2001 From: xc Date: Thu, 21 Aug 2025 14:39:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=98=E5=8E=9Fjson=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aufs/core/sysmonitor.go | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/aufs/core/sysmonitor.go b/aufs/core/sysmonitor.go index 2c711c3..252c724 100644 --- a/aufs/core/sysmonitor.go +++ b/aufs/core/sysmonitor.go @@ -3,6 +3,7 @@ package core import ( "aufs/proto/pb" "encoding/base64" + "encoding/json" "fmt" "log" "net/http" @@ -111,23 +112,23 @@ func SysMonitor(w http.ResponseWriter, r *http.Request) { // ver:0821 // 输出proto encdata := base64.StdEncoding.EncodeToString(hdinfo) - w.Header().Set("content-type", "application/x-protobuf") - w.Write([]byte(encdata)) + // w.Header().Set("content-type", "application/x-protobuf") + // w.Write([]byte(encdata)) // make json string - // jsondata, err := json.Marshal(hdinfo) - // if err != nil { - // http.Error(w, err.Error(), http.StatusInternalServerError) - // } + jsondata, err := json.Marshal(hdinfo) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } - // w.Header().Set("Content-Type", "application/json") + w.Header().Set("Content-Type", "application/json") // 生成json数据 - // jsondata, err = json.Marshal(SysResp{ - // Status: 0, - // Message: "success", - // Data: hdinfo, - // }) - // - // w.Write(jsondata) + jsondata, err = json.Marshal(SysResp{ + Status: 0, + Message: "success", + Data: encdata, + }) + + w.Write(jsondata) }