diff --git a/go.mod b/go.mod index be87eb9..6798ca7 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.13 require ( github.com/TylerBrock/colorjson v0.0.0-20180527164720-95ec53f28296 - github.com/fatih/color v1.9.0 // indirect + github.com/fatih/color v1.9.0 github.com/hokaccha/go-prettyjson v0.0.0-20190818114111-108c894c2c0e // indirect github.com/urfave/cli v1.22.2 ) diff --git a/methods/fns.go b/methods/fns.go index debafd6..4266fa6 100644 --- a/methods/fns.go +++ b/methods/fns.go @@ -9,10 +9,12 @@ import ( "net/http" "github.com/TylerBrock/colorjson" + "github.com/fatih/color" ) // Formatresp formats the Response with Indents and Colors func formatresp(resp *http.Response) string { + c := color.New(color.FgCyan) body, err := ioutil.ReadAll(resp.Body) str := string(body) var obj map[string]interface{} @@ -20,12 +22,16 @@ func formatresp(resp *http.Response) string { f := colorjson.NewFormatter() f.Indent = 6 s, _ := f.Marshal(obj) + for key, value := range resp.Header { + c.Print(key, " : ", value, "\n") + } retbody := fmt.Sprintf("\nStatus:\t\t%s\n\nStatusCode:\t%d\n\n%s\n", resp.Status, resp.StatusCode, string(s)) if err != nil { log.Println("Error on response.\n[ERRO] -", err) } return retbody } + func basicAuth(username, password string) string { auth := username + ":" + password return base64.StdEncoding.EncodeToString([]byte(auth))