mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-10 23:10:32 +00:00
TRA-3234 Fetch command (#54)
* preparation to fetch command * get har as zip from server * no message * no message
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"log"
|
||||
@@ -43,7 +44,6 @@ func ReverseSlice(data interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func CheckErr(e error) {
|
||||
if e != nil {
|
||||
log.Printf("%v", e)
|
||||
@@ -51,7 +51,6 @@ func CheckErr(e error) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func SetHostname(address, newHostname string) string {
|
||||
replacedUrl, err := url.Parse(address)
|
||||
if err != nil{
|
||||
@@ -81,3 +80,8 @@ func GetResolvedBaseEntry(entry models.MizuEntry) models.BaseEntryDetails {
|
||||
RequestSenderIp: entry.RequestSenderIp,
|
||||
}
|
||||
}
|
||||
|
||||
func GetBytesFromStruct(v interface{}) []byte{
|
||||
a, _ := json.Marshal(v)
|
||||
return a
|
||||
}
|
20
api/pkg/utils/zip.go
Normal file
20
api/pkg/utils/zip.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"bytes"
|
||||
)
|
||||
|
||||
func ZipData(files map[string][]byte) *bytes.Buffer {
|
||||
// Create a buffer to write our archive to.
|
||||
buf := new(bytes.Buffer)
|
||||
// Create a new zip archive.
|
||||
zipWriter := zip.NewWriter(buf)
|
||||
defer func() { _ = zipWriter.Close() }()
|
||||
|
||||
for fileName, fileBytes := range files {
|
||||
zipFile, _ := zipWriter.Create(fileName)
|
||||
_, _ = zipFile.Write(fileBytes)
|
||||
}
|
||||
return buf
|
||||
}
|
Reference in New Issue
Block a user