-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat(gensupport): pass in headers via context #2052
Conversation
This allows headers added to the context metadata to be applied to the request. See googleapis/gax-go#291.
internal/gensupport/send.go
Outdated
for k, vals := range headers { | ||
for _, v := range vals { | ||
req.Header.Add(k, v) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean by the nested loop...alternatively, you could do this:
for k, vals := range headers {
req.Header.Set(k, append(r.Header.Get(k), vals...))
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @noahdietz , I think I'll just stick with what I have since it's slightly clearer to look at to me if that's okay.
Merge-on-green attempted to merge your PR for 6 hours, but it was not mergeable because either one of your required status checks failed, one of your required reviews was not approved, or there is a do not merge label. Learn more about your required status checks here: https://help.github.com/en/github/administering-a-repository/enabling-required-status-checks. You can remove and reapply the label to re-run the bot. |
Here is the failing test (save you a click)
|
Thanks, yeah I started looking into this and interestingly it's possible for the context to be nil here. I think the storage veneer always sets the context on the request but two tests do not. I'm wondering whether the check for a nil context should happen in this library, or in the gax function -- any thoughts? |
The
So I don't think we should handle the |
So I think it's a bit more complicated in this case because of how the surface is designed. The Apiary methods do not take a context as a required arg but rather a user would have to know to pass it in using a helper method. E.g. the veneer library does this to make an upload call:
The veneer library of course adds |
TIL! Yeah this sounds right to me, thanks for explaining. |
This allows headers added to the context metadata to be applied to the request. See googleapis/gax-go#291.
Needs a release & version bump of gax-go to work.