Correct context uses

`doAPI`'s `context` does not work due to `WithContext` immutability.
`Authenticate` and `RegisterApp` does not use `context` although they
needs `context`, so their `context` does not work also. This commit fixes
them and add test cases.
This commit is contained in:
TSUYUSATO Kitsune 2017-04-19 18:26:12 +09:00
parent 909a57c5ea
commit fb53d41dd9
5 changed files with 100 additions and 2 deletions

View file

@ -89,6 +89,7 @@ func (c *Client) streaming(ctx context.Context, p string, params url.Values) (ch
}
req, err := http.NewRequest(http.MethodGet, u.String(), in)
if err == nil {
req = req.WithContext(ctx)
req.Header.Set("Authorization", "Bearer "+c.config.AccessToken)
resp, err = c.Do(req)
if resp != nil && resp.StatusCode != http.StatusOK {
@ -114,7 +115,6 @@ func (c *Client) streaming(ctx context.Context, p string, params url.Values) (ch
}
}()
return q, nil
}
// StreamingPublic return channel to read events on public.