fix: error mml return

This commit is contained in:
2024-02-19 11:05:00 +08:00
parent c37946c07e
commit f51caded55

View File

@@ -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]`) // 匹配包含␛的控制字符