Provide a transport constructor for transporters with a cache.

This commit is contained in:
Burcu Dogan
2014-05-26 14:45:41 +02:00
parent 909f098dcd
commit 58513eb0ea
4 changed files with 39 additions and 45 deletions

View File

@@ -95,13 +95,6 @@ func NewAuthorizedTransport(fetcher TokenFetcher, token *Token) Transport {
func (t *authorizedTransport) RoundTrip(req *http.Request) (resp *http.Response, err error) {
token := t.Token()
// Try to initialize the token from the cache.
if token == nil {
if c := t.fetcher.Cache(); c != nil {
token = c.Token()
}
}
if token == nil || token.Expired() {
// Check if the token is refreshable.
// If token is refreshable, don't return an error,