From 802d301cb525c4ed02e80c4aa933aaa0e423dc5e Mon Sep 17 00:00:00 2001 From: r0n1n7an Date: Fri, 22 Nov 2024 15:29:30 +0800 Subject: [PATCH] http status code of api racs/getfaillist base on return result --- APIServer.go | 7 +++++-- APIServer.yml | 6 +----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/APIServer.go b/APIServer.go index 633c8df..0af390d 100644 --- a/APIServer.go +++ b/APIServer.go @@ -585,7 +585,6 @@ func handleRacsGetFailList(w http.ResponseWriter, r *http.Request) { "[]{", "[", "}},", "}],", ) - if rst["List"] != nil { jsonData, err := json.MarshalIndent(rst, "", "\t") if err != nil { @@ -600,7 +599,11 @@ func handleRacsGetFailList(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "%v", rpl.Replace(string(jsonData))) return } - w.WriteHeader(http.StatusOK) + if rst["Result"] != "OK" { + w.WriteHeader(http.StatusInternalServerError) + } else { + w.WriteHeader(http.StatusOK) + } fmt.Fprintf(w, "%v", rpl.Replace(fmt.Sprintf("%#v", rst))) } diff --git a/APIServer.yml b/APIServer.yml index 90fe696..dac17dd 100644 --- a/APIServer.yml +++ b/APIServer.yml @@ -18,8 +18,4 @@ MySQL: OfflineView: v_offline StorageTable: racs GetFailListSQL: SELECT * FROM v_racs -Remark: - Columns_UutInfo: [usn,mac,ipaddr,status,message,first_ack,last_ack,last_change] - Columns_LocInfo: [mac,line,col,row,num,last_found] - USER_RO: ewsv3:ewsv3 - USER_RW: apisvc:wcqte +