Make redirect middleware can use path
Signed-off-by: MATSUMOTO TAKEAKI <takeaki.matsumoto@linecorp.com>
This commit is contained in:
parent
53e18a9d9b
commit
a1cfd267c8
1 changed files with 5 additions and 1 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue