From 16dfd708956604162c6a5d7d3cb907c84f05e7f4 Mon Sep 17 00:00:00 2001 From: athul Date: Tue, 11 Feb 2020 20:43:20 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0Updated=20the=20Formatting=20of=20G?= =?UTF-8?q?Et=20Request?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 ++++++++- methods/send.go | 13 +++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f23a3b7..8606f37 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,14 @@ Putting Simply: **Just pass the URL to the request method** - PUT : `pwcli put < -t/-u/-p > -c/--content type -b/--body ` - DELETE: `pwcli delete < -t/-u/-p > -c/--content type -b/--body ` -## Extra +**Content Types can be of** +`html` : `text/html` +`js` : `application/json`, +`xml` : `application/xml` +`plain` : `text/plain`, + + +`` Extra **SEND**: This can be used to test multiple endpoints from the `postwoman-collection.json` file. The output will only be the `statuscode`. RUN: `pwcli send ` OUTPUT: diff --git a/methods/send.go b/methods/send.go index 6fa61ec..12adaae 100644 --- a/methods/send.go +++ b/methods/send.go @@ -63,16 +63,20 @@ func ReadCollection(c *cli.Context) { } } -func request(c []Colls, i int) { +func request(c []Colls, i int) error { colors := color.New(color.FgHiRed, color.Bold) + fURL := colors.Sprintf(c[0].Request[i].URL + c[0].Request[i].Path) + // if err != nil { + // fmt.Printf("%s\n", err.Error()) + // return nil + //} if c[0].Request[i].Method == "GET" { out, err := getsend(c, i, "GET") if err != nil { fmt.Print(err) } methods := color.HiYellowString(c[0].Request[i].Method) - fURL := colors.Sprintf(c[0].Request[i].URL + c[0].Request[i].Path) - fmt.Printf("%s \t%s\t%s", fURL, methods, out) + fmt.Printf("%s |\t%s |\t%s |\t%s", color.HiGreenString(c[0].Request[i].Name), fURL, methods, out) } else { out, err := sendpopa(c, i, c[0].Request[i].Method) if err != nil { @@ -82,11 +86,12 @@ func request(c []Colls, i int) { fURL := colors.Sprintf(c[0].Request[i].URL + c[0].Request[i].Path) fmt.Printf("%s |\t%s |\t%s |\t%s", color.HiGreenString(c[0].Request[i].Name), fURL, methods, out) } - + return nil } func getsend(c []Colls, ind int, method string) (string, error) { color := color.New(color.FgCyan, color.Bold) var url = c[0].Request[ind].URL + c[0].Request[ind].Path + //fmt.Print(url + " ") req, err := http.NewRequest(method, url, nil) if err != nil { return "", err