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")