mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
add bucket name in the redirection
This commit is contained in:
parent
25fb6f9a46
commit
f5471bcebf
|
@ -61,13 +61,16 @@ func (s3a *S3ApiServer) PutObjectHandler(w http.ResponseWriter, r *http.Request)
|
||||||
|
|
||||||
func (s3a *S3ApiServer) GetObjectHandler(w http.ResponseWriter, r *http.Request) {
|
func (s3a *S3ApiServer) GetObjectHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
bucket := vars["bucket"]
|
||||||
|
|
||||||
if strings.HasSuffix(r.URL.Path, "/") {
|
if strings.HasSuffix(r.URL.Path, "/") {
|
||||||
writeErrorResponse(w, ErrNotImplemented, r.URL)
|
writeErrorResponse(w, ErrNotImplemented, r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
destUrl := fmt.Sprintf("http://%s%s%s",
|
destUrl := fmt.Sprintf("http://%s%s/%s%s",
|
||||||
s3a.option.Filer, s3a.option.BucketsPath, r.RequestURI)
|
s3a.option.Filer, s3a.option.BucketsPath, bucket, r.RequestURI)
|
||||||
|
|
||||||
s3a.proxyToFiler(w, r, destUrl, passThroghResponse)
|
s3a.proxyToFiler(w, r, destUrl, passThroghResponse)
|
||||||
|
|
||||||
|
@ -75,8 +78,11 @@ func (s3a *S3ApiServer) GetObjectHandler(w http.ResponseWriter, r *http.Request)
|
||||||
|
|
||||||
func (s3a *S3ApiServer) HeadObjectHandler(w http.ResponseWriter, r *http.Request) {
|
func (s3a *S3ApiServer) HeadObjectHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
destUrl := fmt.Sprintf("http://%s%s%s",
|
vars := mux.Vars(r)
|
||||||
s3a.option.Filer, s3a.option.BucketsPath, r.RequestURI)
|
bucket := vars["bucket"]
|
||||||
|
|
||||||
|
destUrl := fmt.Sprintf("http://%s%s/%s%s",
|
||||||
|
s3a.option.Filer, s3a.option.BucketsPath, bucket, r.RequestURI)
|
||||||
|
|
||||||
s3a.proxyToFiler(w, r, destUrl, passThroghResponse)
|
s3a.proxyToFiler(w, r, destUrl, passThroghResponse)
|
||||||
|
|
||||||
|
@ -84,8 +90,11 @@ func (s3a *S3ApiServer) HeadObjectHandler(w http.ResponseWriter, r *http.Request
|
||||||
|
|
||||||
func (s3a *S3ApiServer) DeleteObjectHandler(w http.ResponseWriter, r *http.Request) {
|
func (s3a *S3ApiServer) DeleteObjectHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
destUrl := fmt.Sprintf("http://%s%s%s",
|
vars := mux.Vars(r)
|
||||||
s3a.option.Filer, s3a.option.BucketsPath, r.RequestURI)
|
bucket := vars["bucket"]
|
||||||
|
|
||||||
|
destUrl := fmt.Sprintf("http://%s%s/%s%s",
|
||||||
|
s3a.option.Filer, s3a.option.BucketsPath, bucket, r.RequestURI)
|
||||||
|
|
||||||
s3a.proxyToFiler(w, r, destUrl, func(proxyResonse *http.Response, w http.ResponseWriter) {
|
s3a.proxyToFiler(w, r, destUrl, func(proxyResonse *http.Response, w http.ResponseWriter) {
|
||||||
for k, v := range proxyResonse.Header {
|
for k, v := range proxyResonse.Header {
|
||||||
|
|
|
@ -71,10 +71,10 @@ func (s3a *S3ApiServer) registerRouter(router *mux.Router) {
|
||||||
// DeleteBucket
|
// DeleteBucket
|
||||||
bucket.Methods("DELETE").HandlerFunc(s3a.DeleteBucketHandler)
|
bucket.Methods("DELETE").HandlerFunc(s3a.DeleteBucketHandler)
|
||||||
|
|
||||||
// GetObject, but directory listing is not supported
|
|
||||||
bucket.Methods("GET").Path("/{object:.+}").HandlerFunc(s3a.GetObjectHandler)
|
|
||||||
// ListObjectsV2
|
// ListObjectsV2
|
||||||
bucket.Methods("GET").HandlerFunc(s3a.ListObjectsV2Handler).Queries("list-type", "2")
|
bucket.Methods("GET").HandlerFunc(s3a.ListObjectsV2Handler).Queries("list-type", "2")
|
||||||
|
// GetObject, but directory listing is not supported
|
||||||
|
bucket.Methods("GET").Path("/{object:.+}").HandlerFunc(s3a.GetObjectHandler)
|
||||||
// ListObjectsV1 (Legacy)
|
// ListObjectsV1 (Legacy)
|
||||||
bucket.Methods("GET").HandlerFunc(s3a.ListObjectsV1Handler)
|
bucket.Methods("GET").HandlerFunc(s3a.ListObjectsV1Handler)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue