Browse files

Add Debug field to Client

  • Loading branch information...
1 parent 6c5ced4 commit 5b72ae9acff36e8cddef140439d262823fdbf764 @edsrzf edsrzf committed Dec 19, 2011
Showing with 10 additions and 3 deletions.
  1. +10 −3 ironmq.go
View
13 ironmq.go
@@ -11,14 +11,15 @@ import (
// A Client contains an Iron.io project ID and a token for authentication.
type Client struct {
+ Debug bool
projectId string
token string
}
// NewClient returns a new Client using the given project ID and token.
// The network is not used during this call.
func NewClient(projectId, token string) *Client {
- return &Client{projectId, token}
+ return &Client{projectId: projectId, token: token}
}
type Error struct {
@@ -46,8 +47,14 @@ func (c *Client) req(method, endpoint string, body []byte) (map[string]interface
return nil, err
}
- //dump, _ := http.DumpResponse(resp, true)
- //fmt.Printf("%s\n", dump)
+ if c.Debug {
+ dump, err := http.DumpResponse(resp, true)
+ if err != nil {
+ fmt.Println("error dumping response:", err)
+ } else {
+ fmt.Printf("%s\n", dump)
+ }
+ }
jDecoder := json.NewDecoder(resp.Body)
data := map[string]interface{}{}

0 comments on commit 5b72ae9

Please sign in to comment.