|
|
@ -1,13 +1,15 @@ |
|
|
|
package minio |
|
|
|
package gateway |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"errors" |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
"github.com/gorilla/mux" |
|
|
|
|
|
|
|
"github.com/tchap/go-patricia/patricia" |
|
|
|
|
|
|
|
"io/ioutil" |
|
|
|
"io/ioutil" |
|
|
|
"net/http" |
|
|
|
"net/http" |
|
|
|
"path" |
|
|
|
"path" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/gorilla/mux" |
|
|
|
|
|
|
|
"github.com/minio-io/minio/pkgs/storage" |
|
|
|
|
|
|
|
"github.com/tchap/go-patricia/patricia" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// Stores system configuration, populated from CLI or test runner
|
|
|
|
// Stores system configuration, populated from CLI or test runner
|
|
|
@ -195,14 +197,14 @@ func InMemoryStorageDriver(bucket string, input chan ObjectRequest, config Gatew |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func SimpleFileStorageDriver(bucket string, input chan ObjectRequest, config GatewayConfig) { |
|
|
|
func SimpleFileStorageDriver(bucket string, input chan ObjectRequest, config GatewayConfig) { |
|
|
|
storage := FileStorage{ |
|
|
|
fileStorage := storage.FileStorage{ |
|
|
|
RootDir: config.dataDir, |
|
|
|
RootDir: config.dataDir, |
|
|
|
} |
|
|
|
} |
|
|
|
for request := range input { |
|
|
|
for request := range input { |
|
|
|
switch request.requestType { |
|
|
|
switch request.requestType { |
|
|
|
case "GET": |
|
|
|
case "GET": |
|
|
|
objectPath := path.Join(bucket, request.path) |
|
|
|
objectPath := path.Join(bucket, request.path) |
|
|
|
object, err := storage.Get(objectPath) |
|
|
|
object, err := fileStorage.Get(objectPath) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
request.callback <- nil |
|
|
|
request.callback <- nil |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -210,7 +212,7 @@ func SimpleFileStorageDriver(bucket string, input chan ObjectRequest, config Gat |
|
|
|
} |
|
|
|
} |
|
|
|
case "PUT": |
|
|
|
case "PUT": |
|
|
|
objectPath := path.Join(bucket, request.path) |
|
|
|
objectPath := path.Join(bucket, request.path) |
|
|
|
storage.Put(objectPath, request.object) |
|
|
|
fileStorage.Put(objectPath, request.object) |
|
|
|
request.callback <- nil |
|
|
|
request.callback <- nil |
|
|
|
default: |
|
|
|
default: |
|
|
|
request.callback <- errors.New("Unexpected message") |
|
|
|
request.callback <- errors.New("Unexpected message") |