{"action":"created","issue":{"url":"https://api.github.com/repos/gorilla/http/issues/25","labels_url":"https://api.github.com/repos/gorilla/http/issues/25/labels{/name}","comments_url":"https://api.github.com/repos/gorilla/http/issues/25/comments","events_url":"https://api.github.com/repos/gorilla/http/issues/25/events","html_url":"https://github.com/gorilla/http/issues/25","id":108410888,"number":25,"title":"golang.org/x/net/context support?","user":{"login":"arschles","id":70865,"avatar_url":"https://avatars.githubusercontent.com/u/70865?v=3","gravatar_id":"","url":"https://api.github.com/users/arschles","html_url":"https://github.com/arschles","followers_url":"https://api.github.com/users/arschles/followers","following_url":"https://api.github.com/users/arschles/following{/other_user}","gists_url":"https://api.github.com/users/arschles/gists{/gist_id}","starred_url":"https://api.github.com/users/arschles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arschles/subscriptions","organizations_url":"https://api.github.com/users/arschles/orgs","repos_url":"https://api.github.com/users/arschles/repos","events_url":"https://api.github.com/users/arschles/events{/privacy}","received_events_url":"https://api.github.com/users/arschles/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-25T21:27:16Z","updated_at":"2015-09-28T20:46:00Z","closed_at":null,"body":"Have the authors considered using [`golang.org/x/net/context`](http://godoc.org/golang.org/x/net/context) as a mechanism for controlling timeouts?\r\n\r\nThe idea would be that the caller would pass in a `context.Context` and implementation would cancel in-flight requests if the `<-chan struct{}` returned by `ctx.Done()` receives.\r\n\r\nFor example, `Do` would add a `context.Context` as its first argument:\r\n\r\n```go\r\nfunc (c *Client) Do(ctx context.Context, method, url string, headers map[string][]string, body io.Reader) (client.Status, map[string][]string, io.ReadCloser, error)\r\n```\r\n\r\nAnd usage would look like:\r\n\r\n```go\r\n// spend no more than 1 second from request initiation to response return\r\nctx, cancel := context.WithTimeout(context.Background(), 1 * time.Second) \r\ndefer cancel()\r\n_, err := http.Do(ctx, \"POST\", \"http://www.gorillatoolkit.org/\", make(map[string][]string), strings.NewReader(\"POST body goes here\"))\r\n// ...\r\n```\r\n\r\nI'm happy to submit a proposal pull request for this if interested, wanted to float the idea here first.\r\n\r\nReference material on context: https://blog.golang.org/context (see bottom near the `httpDo` func)"},"comment":{"url":"https://api.github.com/repos/gorilla/http/issues/comments/143869003","html_url":"https://github.com/gorilla/http/issues/25#issuecomment-143869003","issue_url":"https://api.github.com/repos/gorilla/http/issues/25","id":143869003,"user":{"login":"arschles","id":70865,"avatar_url":"https://avatars.githubusercontent.com/u/70865?v=3","gravatar_id":"","url":"https://api.github.com/users/arschles","html_url":"https://github.com/arschles","followers_url":"https://api.github.com/users/arschles/followers","following_url":"https://api.github.com/users/arschles/following{/other_user}","gists_url":"https://api.github.com/users/arschles/gists{/gist_id}","starred_url":"https://api.github.com/users/arschles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arschles/subscriptions","organizations_url":"https://api.github.com/users/arschles/orgs","repos_url":"https://api.github.com/users/arschles/repos","events_url":"https://api.github.com/users/arschles/events{/privacy}","received_events_url":"https://api.github.com/users/arschles/received_events","type":"User","site_admin":false},"created_at":"2015-09-28T20:46:00Z","updated_at":"2015-09-28T20:46:00Z","body":"@elithrar I was thinking that adding this kind of support would encapsulate the custom `http.Transport` work that the client of this library would have to do"}}