Skip to content
This repository has been archived by the owner on Jul 14, 2022. It is now read-only.

Commit

Permalink
🛠Updated the Formatting of GEt Request
Browse files Browse the repository at this point in the history
  • Loading branch information
athul committed Feb 11, 2020
1 parent ae46654 commit 16dfd70
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ Putting Simply: **Just pass the URL to the request method**
- PUT : `pwcli put <url> < -t/-u/-p > -c/--content type <content type> -b/--body <body>`
- DELETE: `pwcli delete <url> < -t/-u/-p > -c/--content type <content type> -b/--body <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 <PATH to postwoman collection.json>`
OUTPUT:
Expand Down
13 changes: 9 additions & 4 deletions methods/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 16dfd70

Please sign in to comment.