diff --git a/internal/builtin/function.go b/internal/builtin/function.go index ddeb13b..e69dd4e 100644 --- a/internal/builtin/function.go +++ b/internal/builtin/function.go @@ -10,7 +10,6 @@ import ( "math" "math/rand" "path/filepath" - "reflect" "strings" "time" @@ -131,33 +130,15 @@ func Dump2YAML(data interface{}, path string) error { return nil } -func formatValue(raw interface{}) interface{} { - rawValue := reflect.ValueOf(raw) - switch rawValue.Kind() { - case reflect.Map: - m := make(map[string]interface{}) - for key, value := range rawValue.Interface().(map[string]interface{}) { - fmtValue, ok := value.(string) - if !ok { - b, _ := json.MarshalIndent(&value, "", " ") - fmtValue = string(b) - } - m[key] = fmtValue - } - return m - case reflect.Slice: - b, _ := json.MarshalIndent(&raw, "", " ") - return string(b) - default: - return raw - } -} - func FormatResponse(raw interface{}) interface{} { formattedResponse := make(map[string]interface{}) for key, value := range raw.(map[string]interface{}) { // convert value to json - formattedResponse[key] = formatValue(value) + if key == "body" { + b, _ := json.MarshalIndent(&value, "", " ") + value = string(b) + } + formattedResponse[key] = value } return formattedResponse } diff --git a/internal/report/template.html b/internal/report/template.html index 7aaab2f..978f215 100644 --- a/internal/report/template.html +++ b/internal/report/template.html @@ -273,10 +273,6 @@
{{$k}}: {{$v}}{{- end -}} - {{- else if eq $key "body" }} - {{- range $k, $v := $value }} -
{{$k}}: {{$v}}- {{- end -}} {{- else if eq $key "cookies" }} {{- range $k, $v := $value }}
{{$k}}: {{$v}}