From c254a669e8b878d753b4bb760be6808169ddfaae Mon Sep 17 00:00:00 2001 From: "mayur.popli" Date: Wed, 26 Mar 2025 12:10:56 +0530 Subject: [PATCH] fix: resolved comments --- pkg/response/response.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/pkg/response/response.go b/pkg/response/response.go index 98a5fd4..c44cad0 100644 --- a/pkg/response/response.go +++ b/pkg/response/response.go @@ -33,15 +33,11 @@ func SendAck(w http.ResponseWriter) { }, } - data, err := json.Marshal(resp) - if err != nil { - http.Error(w, "failed to marshal response", http.StatusInternalServerError) - return - } + data, _ := json.Marshal(resp) //should not fail here w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) - _, err = w.Write(data) + _, err := w.Write(data) if err != nil { http.Error(w, "failed to write response", http.StatusInternalServerError) return @@ -57,12 +53,7 @@ func nack(w http.ResponseWriter, err *model.Error, status int, ctx context.Conte Error: err, }, } - data, jsonErr := json.Marshal(resp) - if jsonErr != nil { - fmt.Printf("Error marshaling response: %v, MessageID: %s", jsonErr, ctx.Value(model.MsgIDKey)) - http.Error(w, fmt.Sprintf("Internal server error, MessageID: %s", ctx.Value(model.MsgIDKey)), http.StatusInternalServerError) - return - } + data, _ := json.Marshal(resp) //should not fail here w.Header().Set("Content-Type", "application/json") w.WriteHeader(status)