From 566eab3527c3998a6afd3c759532ef3402fbf7f5 Mon Sep 17 00:00:00 2001 From: RamiBerm Date: Tue, 6 Jul 2021 13:47:15 +0300 Subject: [PATCH] Update entries_controller.go and models.go --- api/pkg/controllers/entries_controller.go | 9 ++++++--- api/pkg/models/models.go | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/api/pkg/controllers/entries_controller.go b/api/pkg/controllers/entries_controller.go index f8645c38a..a2139b297 100644 --- a/api/pkg/controllers/entries_controller.go +++ b/api/pkg/controllers/entries_controller.go @@ -93,13 +93,16 @@ func GetHARs(c *fiber.Ctx) error { harEntry.Request.URL = utils.SetHostname(harEntry.Request.URL, entryData.ResolvedDestination) } + var fileName string sourceOfEntry := entryData.ResolvedSource if sourceOfEntry != "" { // naively assumes the proper service source is http sourceOfEntry = fmt.Sprintf("http://%s", sourceOfEntry) + //replace / from the file name cause they end up creating a corrupted folder + fileName = fmt.Sprintf("%s.har", strings.ReplaceAll(sourceOfEntry, "/", "_")) + } else { + fileName = "unknown_source.har" } - //replace / from the file name cause they end up creating a corrupted folder - fileName := fmt.Sprintf("%s.har", strings.ReplaceAll(sourceOfEntry, "/", "_")) if harOfSource, ok := harsObject[fileName]; ok { harOfSource.Log.Entries = append(harOfSource.Log.Entries, &harEntry) } else { @@ -119,7 +122,7 @@ func GetHARs(c *fiber.Ctx) error { } // leave undefined when no source is present, otherwise modeler assumes source is empty string "" if sourceOfEntry != "" { - harsObject[fileName].Log.Creator.Source = sourceOfEntry + harsObject[fileName].Log.Creator.Source = &sourceOfEntry } } } diff --git a/api/pkg/models/models.go b/api/pkg/models/models.go index a45124255..232a5c1f8 100644 --- a/api/pkg/models/models.go +++ b/api/pkg/models/models.go @@ -105,5 +105,5 @@ type ExtendedLog struct { type ExtendedCreator struct { *har.Creator - Source string `json:"_source"` + Source *string `json:"_source"` }