mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-06 13:01:19 +00:00
Show HTTP path segments as a list of strings in the right pane (#641)
* Show HTTP path segments as a list of strings in the right pane * Use better variable names
This commit is contained in:
@@ -3,14 +3,15 @@ package main
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/up9inc/mizu/tap/api"
|
||||
)
|
||||
|
||||
func mapSliceRebuildAsMap(mapSlice []interface{}) (newMap map[string]interface{}) {
|
||||
newMap = make(map[string]interface{})
|
||||
for _, header := range mapSlice {
|
||||
h := header.(map[string]interface{})
|
||||
for _, item := range mapSlice {
|
||||
h := item.(map[string]interface{})
|
||||
newMap[h["name"].(string)] = h["value"]
|
||||
}
|
||||
|
||||
@@ -19,8 +20,8 @@ func mapSliceRebuildAsMap(mapSlice []interface{}) (newMap map[string]interface{}
|
||||
|
||||
func representMapSliceAsTable(mapSlice []interface{}, selectorPrefix string) (representation string) {
|
||||
var table []api.TableData
|
||||
for _, header := range mapSlice {
|
||||
h := header.(map[string]interface{})
|
||||
for _, item := range mapSlice {
|
||||
h := item.(map[string]interface{})
|
||||
selector := fmt.Sprintf("%s[\"%s\"]", selectorPrefix, h["name"].(string))
|
||||
table = append(table, api.TableData{
|
||||
Name: h["name"].(string),
|
||||
@@ -33,3 +34,19 @@ func representMapSliceAsTable(mapSlice []interface{}, selectorPrefix string) (re
|
||||
representation = string(obj)
|
||||
return
|
||||
}
|
||||
|
||||
func representSliceAsTable(slice []interface{}, selectorPrefix string) (representation string) {
|
||||
var table []api.TableData
|
||||
for i, item := range slice {
|
||||
selector := fmt.Sprintf("%s[%d]", selectorPrefix, i)
|
||||
table = append(table, api.TableData{
|
||||
Name: strconv.Itoa(i),
|
||||
Value: item.(interface{}),
|
||||
Selector: selector,
|
||||
})
|
||||
}
|
||||
|
||||
obj, _ := json.Marshal(table)
|
||||
representation = string(obj)
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user