Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client: add method to enable dumping http request/response #184

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joelrebel
Copy link
Member

@joelrebel joelrebel commented Dec 20, 2022

Adds a SetDumper() method on the serverservice client to enable debugging http requests and responses.

SetDumper can be given a io.Writer which could be a os.Stdout/os.Stderr or a file handle, when an io.Writer is set, it would result in the serverservice client writing the http request, responses for debugging.

…esponses

Setting a io.Writer which could be a os.Stdout/os.Stderr or a file
handle, would result in the serverservice client dumping http request,
responses for debugging.
@joelrebel joelrebel requested a review from a team as a code owner December 20, 2022 15:27
@codecov-commenter
Copy link

Codecov Report

Merging #184 (d8d9131) into main (1a2fae9) will decrease coverage by 0.70%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #184      +/-   ##
==========================================
- Coverage   71.27%   70.56%   -0.71%     
==========================================
  Files          35       35              
  Lines        3380     3414      +34     
==========================================
  Hits         2409     2409              
- Misses        721      753      +32     
- Partials      250      252       +2     
Flag Coverage Δ
unittests 70.56% <0.00%> (-0.71%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/api/v1/client.go 72.91% <0.00%> (-1.56%) ⬇️
pkg/api/v1/requests.go 43.61% <0.00%> (-22.52%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

// SetDumper sets requests and responses to be written to the given writer for debugging.
func (c *Client) SetDumper(w io.Writer) {
c.dumper = w
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uhm... the client already wraps the http client with the Doer interface in this file at line 23. Why not write a wrapper around that instead of adding direct calls to the dumper?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apologies, I haven't responded here sooner - I'll be testing this suggestion out to see if it works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants