octokit/go-octokit — pull request #60 by jingweno (2014-04-01 18:44:13+00:00)
Title: Introduce Middleware system to octokit

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 an extension point. A use case in the new Hub:

```go
type HubTestMiddleware struct {}
func (m *HubTestMiddleware) PrepareRequest(req *octokit.Request) error {
req.Header.Set("X-HUB-HOST", "api.github.com")
}
func (m *HubTestMiddleware) PrepareResponse(resp *octokit.Response) error {
return nil
}

...

client.Use(&HubTestMiddleware{})
```

And [the cuke](https://github.com/github/hub/blob/master/features/fork.feature#L14) would be able to receive some custom headers.