Make redirect middleware can use path

Signed-off-by: MATSUMOTO TAKEAKI <takeaki.matsumoto@linecorp.com>
This commit is contained in:
MATSUMOTO TAKEAKI 2020-07-17 13:58:06 +09:00 committed by Milos Gajdos
parent 53e18a9d9b
commit a1cfd267c8
No known key found for this signature in database
GPG Key ID: 01300E5E6D417439
1 changed files with 5 additions and 1 deletions

View File

@ -13,6 +13,7 @@ type redirectStorageMiddleware struct {
storagedriver.StorageDriver
scheme string
host string
path string
}
var _ storagedriver.StorageDriver = &redirectStorageMiddleware{}
@ -37,10 +38,13 @@ func newRedirectStorageMiddleware(sd storagedriver.StorageDriver, options map[st
return nil, fmt.Errorf("no host specified for redirect baseurl")
}
return &redirectStorageMiddleware{StorageDriver: sd, scheme: u.Scheme, host: u.Host}, nil
return &redirectStorageMiddleware{StorageDriver: sd, scheme: u.Scheme, host: u.Host, path: u.Path}, nil
}
func (r *redirectStorageMiddleware) URLFor(ctx context.Context, path string, options map[string]interface{}) (string, error) {
if r.path != "" {
path = r.path + path
}
u := &url.URL{Scheme: r.scheme, Host: r.host, Path: path}
return u.String(), nil
}