s3cache: expose add'l config options as URL params

this should allow using at least some s3-compatible services like minio.

Fixes #120, #147
This commit is contained in:
Will Norris 2019-01-12 06:37:00 +00:00
parent a903995ee7
commit e860748032
2 changed files with 31 additions and 1 deletions

View file

@ -97,7 +97,21 @@ func New(s string) (*cache, error) {
prefix = path[1]
}
sess, err := session.NewSession(&aws.Config{Region: &region})
config := aws.NewConfig().WithRegion(region)
// allow overriding some additional config options, mostly useful when
// working with s3-compatible services other than AWS.
if v := u.Query().Get("endpoint"); v != "" {
config = config.WithEndpoint(v)
}
if v := u.Query().Get("disableSSL"); v == "1" {
config = config.WithDisableSSL(true)
}
if v := u.Query().Get("s3ForcePathStyle"); v == "1" {
config = config.WithS3ForcePathStyle(true)
}
sess, err := session.NewSession(config)
if err != nil {
return nil, err
}