Skip to content

Commit

Permalink
Merge pull request #32 from andywaltlova/merge-metadata
Browse files Browse the repository at this point in the history
Merge received message metadata with ours
  • Loading branch information
r0x0d authored Jun 30, 2023
2 parents 5cd8dbd + fac614f commit 38ba682
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,9 @@ func (s *jobServer) Send(ctx context.Context, d *pb.Data) (*pb.Receipt, error) {
data = &pb.Data{
MessageId: uuid.New().String(),
ResponseTo: d.GetMessageId(),
Metadata: map[string]string{
"Content-Type": contentType,
},
Content: fileContent.Bytes(),
Directive: d.GetMetadata()["return_url"],
Metadata: constructMetadata(d.GetMetadata(), contentType),
Content: fileContent.Bytes(),
Directive: d.GetMetadata()["return_url"],
}
} else {
data = &pb.Data{
Expand Down
10 changes: 10 additions & 0 deletions src/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,13 @@ func readOutputFile(filePath string) (*bytes.Buffer, string) {
log.Infoln("form-data created, returning body: ", body)
return body, writer.Boundary()
}

func constructMetadata(receivedMetadata map[string]string, contentType string) map[string]string {
ourMetadata := map[string]string{
"Content-Type": contentType,
}
for k, v := range receivedMetadata {
ourMetadata[k] = v
}
return ourMetadata
}

0 comments on commit 38ba682

Please sign in to comment.