Add docs for NewAuthorizedTransportWithCache.

This commit is contained in:
Burcu Dogan 2014-06-17 16:24:27 +02:00
parent 4337573be3
commit db2d8759b4
1 changed files with 5 additions and 1 deletions

View File

@ -86,13 +86,17 @@ type authorizedTransport struct {
mu sync.RWMutex mu sync.RWMutex
} }
// NewAuthorizedTransport creates a tranport that uses the provided // NewAuthorizedTransport creates a transport that uses the provided
// token fetcher to retrieve new tokens if there is no access token // token fetcher to retrieve new tokens if there is no access token
// provided or it is expired. // provided or it is expired.
func NewAuthorizedTransport(fetcher TokenFetcher, token *Token) Transport { func NewAuthorizedTransport(fetcher TokenFetcher, token *Token) Transport {
return &authorizedTransport{fetcher: fetcher, token: token} return &authorizedTransport{fetcher: fetcher, token: token}
} }
// NewAuthorizedTransportWithCache creates a new transport that uses
// the provided token fetcher and cache. Before constructing the new
// transport, it will try to read from the cache to see if there
// is an existing token.
func NewAuthorizedTransportWithCache(fetcher TokenFetcher, cache Cache) (transport Transport, err error) { func NewAuthorizedTransportWithCache(fetcher TokenFetcher, cache Cache) (transport Transport, err error) {
var token *Token var token *Token
if token, err = cache.Read(); err != nil { if token, err = cache.Read(); err != nil {