diff --git a/app/gosqs/send_message.go b/app/gosqs/send_message.go index 70fb41b5..701eb636 100644 --- a/app/gosqs/send_message.go +++ b/app/gosqs/send_message.go @@ -33,6 +33,7 @@ func SendMessageV1(req *http.Request) (int, interfaces.AbstractResponseBody) { queueName := "" if queueUrl == "" { + // TODO: Remove this query param logic if it's not still valid or something vars := mux.Vars(req) queueName = vars["queueName"] } else { @@ -103,7 +104,7 @@ func SendMessageV1(req *http.Request) (int, interfaces.AbstractResponseBody) { } // TODO: -// Refactor internal MessageAttribute model between SendMessage and ReceiveMessage +// Refactor internal model for MessageAttribute between SendMessage and ReceiveMessage // from app.MessageAttributeValue(old) to models.MessageAttributeValue(new) and remove this temporary function. func convertToOldMessageAttributeValueStructure(newValues map[string]models.MessageAttributeValue) map[string]app.MessageAttributeValue { attributes := make(map[string]app.MessageAttributeValue) diff --git a/app/models/models.go b/app/models/models.go index 3c78e3a6..7a7d8d6b 100644 --- a/app/models/models.go +++ b/app/models/models.go @@ -180,11 +180,17 @@ func NewSendMessageRequest() *SendMessageRequest { } type SendMessageRequest struct { - DelaySeconds int `json:"Del1aySeconds" schema:"DelaySeconds"` - MessageAttributes map[string]MessageAttributeValue `json:"MessageAttributes" schema:"MessageAttributes"` - MessageBody string `json:"MessageBody" schema:"MessageBody"` - MessageDeduplicationId string `json:"MessageDeduplicationId" schema:"MessageDeduplicationId"` - MessageGroupId string `json:"MessageGroupId" schema:"MessageGroupId"` + DelaySeconds int `json:"DelaySeconds" schema:"DelaySeconds"` + // MessageAttributes is custom attributes that users can add on the message as they like. + // Please see: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html#SQS-SendMessage-request-MessageAttributes + MessageAttributes map[string]MessageAttributeValue `json:"MessageAttributes" schema:"MessageAttributes"` + MessageBody string `json:"MessageBody" schema:"MessageBody"` + MessageDeduplicationId string `json:"MessageDeduplicationId" schema:"MessageDeduplicationId"` + MessageGroupId string `json:"MessageGroupId" schema:"MessageGroupId"` + // MessageSystemAttributes is custom attributes for AWS services. + // Please see: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html#SQS-SendMessage-request-MessageSystemAttributes + // On AWS, the only supported attribute is AWSTraceHeader that is for AWS X-Ray. + // Goaws does not contains X-Ray emulation, so currently MessageSystemAttributes is unsupported. MessageSystemAttributes map[string]MessageAttributeValue `json:"MessageSystemAttributes" schema:"MessageSystemAttributes"` QueueUrl string `json:"QueueUrl" schema:"QueueUrl"` } diff --git a/app/models/models_test.go b/app/models/models_test.go index 33b52b8b..daefd189 100644 --- a/app/models/models_test.go +++ b/app/models/models_test.go @@ -261,7 +261,7 @@ func TestSendMessageRequest_SetAttributesFromForm_success(t *testing.T) { form.Add("MessageAttribute.1.Value.DataType", "String") form.Add("MessageAttribute.1.Value.StringValue", "Value1") form.Add("MessageAttribute.2.Name", "Attr2") - form.Add("MessageAttribute.2.Value.DataType", "String") + form.Add("MessageAttribute.2.Value.DataType", "Binary") form.Add("MessageAttribute.2.Value.BinaryValue", "VmFsdWUy") form.Add("MessageAttribute.3.Name", "") form.Add("MessageAttribute.3.Value.DataType", "String") @@ -286,7 +286,7 @@ func TestSendMessageRequest_SetAttributesFromForm_success(t *testing.T) { assert.NotNil(t, r.MessageAttributes["Attr2"]) attr2 := r.MessageAttributes["Attr2"] - assert.Equal(t, "String", attr2.DataType) + assert.Equal(t, "Binary", attr2.DataType) assert.Equal(t, "", attr2.StringValue) assert.Equal(t, "VmFsdWUy", attr2.BinaryValue) }