|
|
|
@ -4,7 +4,6 @@ import (
|
|
|
|
|
"bytes"
|
|
|
|
|
"compress/gzip"
|
|
|
|
|
"encoding/hex"
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"errors"
|
|
|
|
|
"fmt"
|
|
|
|
|
"io/ioutil"
|
|
|
|
@ -24,6 +23,7 @@ import (
|
|
|
|
|
"crypto/tls"
|
|
|
|
|
"github.com/jroimartin/gocui"
|
|
|
|
|
"github.com/mattn/go-runewidth"
|
|
|
|
|
"github.com/nwidger/jsoncolor"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const VERSION = "0.1.0"
|
|
|
|
@ -431,10 +431,11 @@ func (a *App) SubmitRequest(g *gocui.Gui, _ *gocui.View) error {
|
|
|
|
|
// pretty-print json
|
|
|
|
|
if strings.Contains(response.Header.Get("Content-Type"), "application/json") &&
|
|
|
|
|
a.config.General.FormatJSON {
|
|
|
|
|
var prettyJSON bytes.Buffer
|
|
|
|
|
err := json.Indent(&prettyJSON, r.RawResponseBody, "", " ")
|
|
|
|
|
formatter := jsoncolor.NewFormatter()
|
|
|
|
|
buf := bytes.NewBuffer(make([]byte, 0, len(r.RawResponseBody)))
|
|
|
|
|
err := formatter.Format(buf, r.RawResponseBody)
|
|
|
|
|
if err == nil {
|
|
|
|
|
r.RawResponseBody = prettyJSON.Bytes()
|
|
|
|
|
r.RawResponseBody = buf.Bytes()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|