From 25cde52fae011ca55b49633651339d86dd7ade25 Mon Sep 17 00:00:00 2001 From: "453530270@qq.com" Date: Tue, 2 Jul 2024 16:36:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Djson=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E7=9A=84=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fssc/internal/handler/nfhandler.go | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/fssc/internal/handler/nfhandler.go b/fssc/internal/handler/nfhandler.go index 4f93fe7..f5d7cbd 100644 --- a/fssc/internal/handler/nfhandler.go +++ b/fssc/internal/handler/nfhandler.go @@ -2,7 +2,6 @@ package handler import ( "encoding/json" - "fmt" "fssc/config" "net/http" "os" @@ -11,8 +10,8 @@ import ( // json 结构体 type Response struct { - Status string `json:"status"` - Message string `json:"data"` + Status string `json:"status"` + Data FilesListJson `json:"data"` } // 文件输出的结构 @@ -52,10 +51,6 @@ func NfTest(w http.ResponseWriter, r *http.Request) { DownloadPath: downloadPath, } - // 文件灌入数组中 - // var gmap map[string]interface{} - // gmap = make(map[string]interface{}) - // list json var flist FilesListJson @@ -70,8 +65,6 @@ func NfTest(w http.ResponseWriter, r *http.Request) { // data.Files = files for _, v := range files { - // gmap[k]["filename"] = v.Name() - // gmap[k]["isdir"] = v.IsDir() flist.Flist = append(flist.Flist, FileJson{Fname: v.Name(), Isdir: v.IsDir()}) } @@ -80,16 +73,10 @@ func NfTest(w http.ResponseWriter, r *http.Request) { flist.Flist = append(flist.Flist, FileJson{Fname: filepath.Base(realFilePath), Isdir: true}) } - // 绑定到jfile - jdata, err := json.Marshal(flist) - if err != nil { - fmt.Printf("gmap has error:%v\n", err) - } - // respone file list response := Response{ - Status: "success", - Message: string(jdata), + Status: "success", + Data: flist, } // w.Header().Set("Content-Type", "application/json")