making the debug print pretty

This commit is contained in:
jackspirou 2015-11-20 19:39:05 -06:00
parent 099c8ee9aa
commit d9380902f2
2 changed files with 4 additions and 11 deletions

13
main.go
View File

@ -112,7 +112,7 @@ func main() {
}
defer resp.Body.Close()
if vargs.Verbose || os.Getenv("DEBUG") == "true" {
if vargs.Debug || os.Getenv("DEBUG") == "true" {
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
@ -121,15 +121,8 @@ func main() {
fmt.Printf("Error reading http response body. %s\n", err)
}
// scrub out basic auth pass
/*
if len(vargs.Auth.Password) > 0 {
req.SetBasicAuth(vargs.Auth.Username, "XXXXX")
}
*/
// print out
fmt.Printf("Webhook URL %d\n URL: %s\n METHOD: %s\n HEADERS: %s\n BODY: %s\n RESPONSE STATUS: %s\n RESPONSE: %s\n", i+1, req.URL, req.Method, req.Header, string(b), resp.Status, string(body))
// debug print
fmt.Printf("[debug] Webhook %d\n URL: %s\n METHOD: %s\n HEADERS: %s\n REQUEST BODY: %s\n RESPONSE STATUS: %s\n RESPONSE BODY: %s\n", i+1, req.URL, req.Method, req.Header, string(b), resp.Status, string(body))
}
}
}

View File

@ -2,7 +2,7 @@ package main
type Webhook struct {
Urls []string `json:"urls"`
Verbose bool `json:"verbose"`
Debug bool `json:"debug"`
Auth BasicAuth `json:"auth"`
Headers map[string]string `json:"header"`
Method string `json:"method"`