From f51caded5553b7fa271bf1199d159a6769832926 Mon Sep 17 00:00:00 2001 From: simonzhangsz Date: Mon, 19 Feb 2024 11:05:00 +0800 Subject: [PATCH] fix: error mml return --- features/mml/mml.go | 49 ++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/features/mml/mml.go b/features/mml/mml.go index b7ec90e3..5934b664 100644 --- a/features/mml/mml.go +++ b/features/mml/mml.go @@ -242,9 +242,10 @@ func PostMMLToNF(w http.ResponseWriter, r *http.Request) { if err != nil { log.Error("Failed to write:", err) mmlResult = append(mmlResult, err.Error()) - response := Response{mmlResult} - services.ResponseWithJson(w, http.StatusOK, response) - return + //response := Response{mmlResult} + //services.ResponseWithJson(w, http.StatusOK, response) + //return + continue } time.Sleep(time.Millisecond * TIME_DELAY_AFTER_WRITE) mmlCommand := fmt.Sprintf("%s\n", mml) @@ -253,9 +254,10 @@ func PostMMLToNF(w http.ResponseWriter, r *http.Request) { if err != nil { log.Error("Failed to write:", err) mmlResult = append(mmlResult, err.Error()) - response := Response{mmlResult} - services.ResponseWithJson(w, http.StatusOK, response) - return + //response := Response{mmlResult} + //services.ResponseWithJson(w, http.StatusOK, response) + //return + continue } time.Sleep(time.Millisecond * TIME_DELAY_AFTER_WRITE) @@ -263,9 +265,10 @@ func PostMMLToNF(w http.ResponseWriter, r *http.Request) { if err != nil { log.Error("Failed to read:", err) mmlResult = append(mmlResult, err.Error()) - response := Response{mmlResult} - services.ResponseWithJson(w, http.StatusOK, response) - return + //response := Response{mmlResult} + //services.ResponseWithJson(w, http.StatusOK, response) + //return + continue } log.Trace(string(buf[0 : n-len(neType)-2])) @@ -377,9 +380,10 @@ func PostMMLToNF(w http.ResponseWriter, r *http.Request) { if err != nil { log.Error("Failed to write:", err) mmlResult = append(mmlResult, err.Error()) - response := Response{mmlResult} - services.ResponseWithJson(w, http.StatusOK, response) - return + // response := Response{mmlResult} + // services.ResponseWithJson(w, http.StatusOK, response) + // return + continue } time.Sleep(time.Millisecond * TIME_DELAY_AFTER_WRITE) @@ -387,9 +391,10 @@ func PostMMLToNF(w http.ResponseWriter, r *http.Request) { if err != nil { log.Error("Failed to read:", err) mmlResult = append(mmlResult, err.Error()) - response := Response{mmlResult} - services.ResponseWithJson(w, http.StatusOK, response) - return + // response := Response{mmlResult} + // services.ResponseWithJson(w, http.StatusOK, response) + // return + continue } log.Trace(string(buf[0 : n-len(neType)-2])) @@ -466,9 +471,10 @@ func PostMMLToNF(w http.ResponseWriter, r *http.Request) { if err != nil { log.Error("Failed to write:", err) mmlResult = append(mmlResult, err.Error()) - response := Response{mmlResult} - services.ResponseWithJson(w, http.StatusOK, response) - return + // response := Response{mmlResult} + // services.ResponseWithJson(w, http.StatusOK, response) + // return + continue } time.Sleep(time.Millisecond * TIME_DELAY_AFTER_WRITE) @@ -476,9 +482,10 @@ func PostMMLToNF(w http.ResponseWriter, r *http.Request) { if err != nil { log.Error("Failed to read:", err) mmlResult = append(mmlResult, err.Error()) - response := Response{mmlResult} - services.ResponseWithJson(w, http.StatusOK, response) - return + // response := Response{mmlResult} + // services.ResponseWithJson(w, http.StatusOK, response) + // return + continue } log.Trace(string(buf[0 : n-len(neType)-2])) re1 := regexp.MustCompile(`\x1B\[[0-9;]*[a-zA-Z]`) // 匹配包含␛的控制字符