remove cache
This commit is contained in:
19
transport.go
19
transport.go
@@ -76,9 +76,6 @@ type Transport interface {
|
||||
}
|
||||
|
||||
type authorizedTransport struct {
|
||||
// Cache to persist changes to the token that
|
||||
// authorizes the current transport.
|
||||
cache Cache
|
||||
fetcher TokenFetcher
|
||||
token *Token
|
||||
|
||||
@@ -93,19 +90,6 @@ func NewAuthorizedTransport(fetcher TokenFetcher, token *Token) Transport {
|
||||
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) {
|
||||
var token *Token
|
||||
if token, err = cache.Read(); err != nil {
|
||||
return
|
||||
}
|
||||
transport = &authorizedTransport{fetcher: fetcher, cache: cache, token: token}
|
||||
return
|
||||
}
|
||||
|
||||
// RoundTrip authorizes the request with the existing token.
|
||||
// If token is expired, tries to refresh/fetch a new token.
|
||||
func (t *authorizedTransport) RoundTrip(req *http.Request) (resp *http.Response, err error) {
|
||||
@@ -176,9 +160,6 @@ func (t *authorizedTransport) RefreshToken() error {
|
||||
}
|
||||
|
||||
t.token = token
|
||||
if t.cache != nil {
|
||||
return t.cache.Write(token)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user