Prechádzať zdrojové kódy

fix(http):修复HTTP响应状态码错误问题

- 将系统错误时的状态码从400改为200- 移除JSON序列化失败时重复设置的状态码写入逻辑
dcsunny 2 týždňov pred
rodič
commit
56cd55dbd5
1 zmenil súbory, kde vykonal 1 pridanie a 2 odobranie
  1. 1 2
      transport/http/handle.go

+ 1 - 2
transport/http/handle.go

@@ -135,7 +135,7 @@ func ErrHandle(w http.ResponseWriter, r *http.Request, err error) {
 		if code < 10100 && message == "" {
 			message = "系统错误"
 		}
-		w.WriteHeader(400)
+		w.WriteHeader(200)
 	}
 	_reply := reply.SuccessReply{
 		Code:    code,
@@ -149,7 +149,6 @@ func ErrHandle(w http.ResponseWriter, r *http.Request, err error) {
 	}
 	data, err := json2.Marshal(_reply)
 	if err != nil {
-		w.WriteHeader(http.StatusInternalServerError)
 		return
 	}
 	w.Write(data)