code fix as per the review comments
This commit is contained in:
@@ -47,8 +47,8 @@ func nack(ctx context.Context, w http.ResponseWriter, err *model.Error, status i
|
||||
w.WriteHeader(status)
|
||||
_, er := w.Write(data)
|
||||
if er != nil {
|
||||
fmt.Printf("Error writing response: %v, MessageID: %s", er, ctx.Value(model.MsgIDKey))
|
||||
http.Error(w, fmt.Sprintf("Internal server error, MessageID: %s", ctx.Value(model.MsgIDKey)), http.StatusInternalServerError)
|
||||
fmt.Printf("Error writing response: %v, MessageID: %s", er, ctx.Value(model.ContextKeyMsgID))
|
||||
http.Error(w, fmt.Sprintf("Internal server error, MessageID: %s", ctx.Value(model.ContextKeyMsgID)), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ func nack(ctx context.Context, w http.ResponseWriter, err *model.Error, status i
|
||||
func internalServerError(ctx context.Context) *model.Error {
|
||||
return &model.Error{
|
||||
Code: http.StatusText(http.StatusInternalServerError),
|
||||
Message: fmt.Sprintf("Internal server error, MessageID: %s", ctx.Value(model.MsgIDKey)),
|
||||
Message: fmt.Sprintf("Internal server error, MessageID: %s", ctx.Value(model.ContextKeyMsgID)),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ func TestSendAck(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendNack(t *testing.T) {
|
||||
ctx := context.WithValue(context.Background(), model.MsgIDKey, "123456")
|
||||
ctx := context.WithValue(context.Background(), model.ContextKeyMsgID, "123456")
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -197,7 +197,7 @@ func TestNack_1(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ctx := context.WithValue(req.Context(), model.MsgIDKey, "12345")
|
||||
ctx := context.WithValue(req.Context(), model.ContextKeyMsgID, "12345")
|
||||
|
||||
var w http.ResponseWriter
|
||||
if tt.useBadWrite {
|
||||
|
||||
Reference in New Issue
Block a user