From eef58496b5833a34e49ea1bfaf13abf9f5cd0626 Mon Sep 17 00:00:00 2001 From: gadotroee <55343099+gadotroee@users.noreply.github.com> Date: Mon, 5 Jul 2021 17:12:48 +0300 Subject: [PATCH] Add source and destination info when fetching entries (x-mizu-fields) (#93) --- api/pkg/database/main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/pkg/database/main.go b/api/pkg/database/main.go index 4ce4f07db..f14734f85 100644 --- a/api/pkg/database/main.go +++ b/api/pkg/database/main.go @@ -63,6 +63,14 @@ func GetEntriesFromDb(timestampFrom int64, timestampTo int64) []har.Entry { for _, entryData := range entries { var harEntry har.Entry _ = json.Unmarshal([]byte(entryData.Entry), &harEntry) + + if entryData.ResolvedSource != "" { + harEntry.Request.Headers = append(harEntry.Request.Headers, har.Header{Name: "x-mizu-source", Value: entryData.ResolvedSource}) + } + if entryData.ResolvedDestination != "" { + harEntry.Request.Headers = append(harEntry.Request.Headers, har.Header{Name: "x-mizu-destination", Value: entryData.ResolvedDestination}) + } + entriesArray = append(entriesArray, harEntry) } return entriesArray