-
Notifications
You must be signed in to change notification settings - Fork 79
Conversation
I prefer something like the RoundTripper interface to a middleware system. What kind of stuff do you imagine setting in this in Octokit? I figure Octokit should support for various custom headers that the GitHub API needs. |
The intention is to being able to set extra headers so that the cukes of the new Hub are happy. For example, I need to set a
I wonder if there's any problem if I mutate the headers. I'll do more research on that though. Good call on adding more support on the custom headers that GitHub API requires in |
@technoweenie I just read the source of how To use |
I don't think RoundTripper is really intended to modify a header like that. You typically have the actual request object while using the HTTP client, so you can just add your headers there. RoundTripper might be better if you want a specific header on ALL requests. But go-sawyer should give you this capability already. client := sawyer.NewFromString("https://api.github.com")
// header set on EVERY request
client.Headers.Set("Accept", "application/vnd.github+json")
apierr := &ApiError{} // decoded from response body on non-20x responses
user := &User{}
req := client.NewRequest("user/21", apierr)
// header set on just this request
req.Headers.Set("X-Foo", "Bar") |
@technoweenie What do you think of 25a2655? I removed the middleware system and prefer |
* Remove introduced middleware system * Expose `Client.Header` instead for globally applied headers A caveat is that Go doesn't apply `Host` on the header but consulting `Request.Header`. Details see https://code.google.com/p/go/issues/detail?id=7682.
👍 |
Wohoo, merging |
The changes allow us to have callbacks before sending requests and after receiving response (before the JSON deserialization). Previously the request/response cycle is all hidden and this'll open up an extension point. A use case in the new Hub:
And the cuke would be able to receive some custom headers.