mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-05-09 17:48:20 +00:00
added additional debug logging
This commit is contained in:
parent
2a08213258
commit
866ca4e307
1 changed files with 12 additions and 0 deletions
|
@ -83,6 +83,7 @@ func (c *Client) newRequest(method, path string, body interface{}) (*http.Reques
|
||||||
return nil, fmt.Errorf("Parsing URL: %w", err)
|
return nil, fmt.Errorf("Parsing URL: %w", err)
|
||||||
}
|
}
|
||||||
u := c.baseURL.ResolveReference(rel)
|
u := c.baseURL.ResolveReference(rel)
|
||||||
|
|
||||||
var buf io.ReadWriter
|
var buf io.ReadWriter
|
||||||
if body != nil {
|
if body != nil {
|
||||||
buf = new(bytes.Buffer)
|
buf = new(bytes.Buffer)
|
||||||
|
@ -104,6 +105,15 @@ func (c *Client) newRequest(method, path string, body interface{}) (*http.Reques
|
||||||
req.AddCookie(&c.sessionToken)
|
req.AddCookie(&c.sessionToken)
|
||||||
req.AddCookie(&c.csrfToken)
|
req.AddCookie(&c.csrfToken)
|
||||||
|
|
||||||
|
// Debugging
|
||||||
|
c.log("Request URL: %v", req.URL.String())
|
||||||
|
if c.Debug && body != nil {
|
||||||
|
data, err := json.Marshal(body)
|
||||||
|
if err == nil {
|
||||||
|
c.log("Raw Request: %v", string(data))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return req, nil
|
return req, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,6 +137,8 @@ func (c *Client) do(ctx context.Context, req *http.Request, v *APIResponse) (*ht
|
||||||
return resp, fmt.Errorf("Error Reading Resopnse Body: %w", err)
|
return resp, fmt.Errorf("Error Reading Resopnse Body: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.log("Raw Response: %v", string(bodyBytes))
|
||||||
|
|
||||||
err = json.Unmarshal(bodyBytes, v)
|
err = json.Unmarshal(bodyBytes, v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return resp, fmt.Errorf("Unable to Parse JSON API Response with HTTP Status Code %v: %w", resp.StatusCode, err)
|
return resp, fmt.Errorf("Unable to Parse JSON API Response with HTTP Status Code %v: %w", resp.StatusCode, err)
|
||||||
|
|
Loading…
Add table
Reference in a new issue