-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
[refactor][api] rework requireOK(doRequest(r))
usage
#11195
Comments
Can I pick this up ? |
Hi @sidzi, We would welcome a PR for this enhancement - thank you for offering to contribute! Please review the conversation starting at the comment linked above to understand the direction the maintainers think the solution should take. Let us know if you have any follow-up questions. I strongly recommend submitting a draft PR for review in which only 1-2 of the replacements have been made so we can align on approach early (before extending it to all ~140 usages). Perhaps that draft PR can include 1 instance of the common case in which Thanks again! |
Hello, I have two doubts:
^ here we are trying to short-circuit the call so that we can distinguish between doRequest and In a lot of cases we are directly returning the error without any specific handling. Ex :
|
Hi @sidzi , thank you for taking this on! Q1: We cannot close the body within Q2: If you take a look at the comment thread here (#11158) you can see that I propose to remove that "short-circuiting" from func requireHttpCodes(resp *http.Response, httpCodes ...int) (*http.Response, error) and handle errors from |
Thanks for resolving the doubts. I have submitted a draft. Please have a look at this : #11287 |
Overview
During #11158, the team called out the odd ergonomics of
requireOK()
/requireHTTPCodes()
. In particular, fordoRequest()
errors, we close the request body, but not for "require"/ http code errors.There's some ~140 usage of
requireOK()/ requireHTTPCodes()
calls. Depending on the approach taken, a big diff may be generated.Links and References
#11158 (comment)
The text was updated successfully, but these errors were encountered: