Swift storageUrl overloading fixes #167

This commit is contained in:
Xavier Lucas 2016-02-02 20:45:05 +01:00 committed by Nick Craig-Wood
parent 08a8f7174a
commit c2e8f06bfa
3 changed files with 42 additions and 0 deletions

30
swift/auth.go Normal file
View file

@ -0,0 +1,30 @@
package swift
import "github.com/ncw/swift"
// auth is an authenticator for swift
type auth struct {
swift.Authenticator
storageURL string
}
// newAuth creates a swift authenticator wrapper to override the
// StorageUrl method.
func newAuth(Authenticator swift.Authenticator, storageURL string) *auth {
return &auth{
Authenticator: Authenticator,
storageURL: storageURL,
}
}
// The public storage URL - set Internal to true to read
// internal/service net URL
func (a *auth) StorageUrl(Internal bool) string {
if a.storageURL != "" {
return a.storageURL
}
return a.Authenticator.StorageUrl(Internal)
}
// Check the interfaces are satisfied
var _ swift.Authenticator = (*auth)(nil)