Documentation ¶
Index ¶
- Constants
- Variables
- func EncodeResponse(response interface{}) []byte
- func GenerateCompleteMultpartUploadResponse(bucket, key, location, etag string) CompleteMultipartUploadResponse
- func GenerateCopyObjectPartResponse(etag string, lastModified time.Time) CopyObjectPartResponse
- func GenerateCopyObjectResponse(etag string, lastModified time.Time) CopyObjectResponse
- func GenerateInitiateMultipartUploadResponse(bucket, key, uploadID string) InitiateMultipartUploadResponse
- func GenerateListBucketsResponse(buckets []meta.Bucket, credential iam.Credential) ListBucketsResponse
- func GenerateListObjectsResponse(bucketName string, request ListObjectsRequest, ...) (response ListObjectsResponse)
- func GenerateVersionedListObjectResponse(bucketName string, request ListObjectsRequest, ...) (response VersionedListObjectsResponse)
- func GetLocation(r *http.Request) string
- func GetObjectLocation(bucketName string, key string) string
- func InReservedOrigins(origin string) bool
- func RegisterAPIRouter(mux *router.Router, api ObjectAPIHandlers)
- func RegisterHandlers(router *mux.Router, objectLayer ObjectLayer, handlerFns ...HandlerFunc) http.Handler
- func SetAuthHandler(h http.Handler, _ ObjectLayer) http.Handler
- func SetCommonHeaderHandler(h http.Handler, _ ObjectLayer) http.Handler
- func SetCorsHandler(h http.Handler, objectLayer ObjectLayer) http.Handler
- func SetIgnoreResourcesHandler(h http.Handler, _ ObjectLayer) http.Handler
- func SetLogHandler(handler http.Handler, _ ObjectLayer) http.Handler
- func SetObjectHeaders(w http.ResponseWriter, object *meta.Object, contentRange *HttpRange)
- func SetRateLimitHandler(handler http.Handler, _ ObjectLayer) http.Handler
- func WriteErrorResponse(w http.ResponseWriter, r *http.Request, err error)
- func WriteErrorResponseHeaders(w http.ResponseWriter, err error)
- func WriteErrorResponseNoHeader(w http.ResponseWriter, req *http.Request, err error, resource string)
- func WriteErrorResponseWithResource(w http.ResponseWriter, r *http.Request, err error, resource string)
- func WriteSuccessNoContent(w http.ResponseWriter)
- func WriteSuccessResponse(w http.ResponseWriter, response []byte)
- type ApiErrorResponse
- type AuthHandler
- type ContextKey
- type DeleteObjectsResponse
- type HandlerFunc
- type ObjectAPIHandlers
- func (api ObjectAPIHandlers) AbortMultipartUploadHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) DelBucketLifeCycleHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) DeleteBucketCorsHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) DeleteBucketHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) DeleteObjectHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) GetBucketAclHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) GetBucketCorsHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) GetBucketLifeCycleHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) GetBucketLocationHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) GetBucketPolicyHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) GetBucketVersioningHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) GetObjectAclHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) HeadBucketHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) ListBucketsHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) ListMultipartUploadsHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) ListObjectPartsHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) ListObjectsHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) ListVersionedObjectsHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) NewMultipartUploadHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) PutBucketAclHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) PutBucketCorsHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) PutBucketHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) PutBucketLifeCycleHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) PutBucketVersioningHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) PutObjectAclHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Request)
- func (api ObjectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http.Request)
- type ObjectLayer
- type Server
Constants ¶
const (
MIN_PART_SIZE = 128 << 10 // 128KB
)
Variables ¶
var ValidSuccessActionStatus = []string{"200", "201", "204"}
Functions ¶
func EncodeResponse ¶
func EncodeResponse(response interface{}) []byte
Encodes the response headers into XML format.
func GenerateCompleteMultpartUploadResponse ¶
func GenerateCompleteMultpartUploadResponse(bucket, key, location, etag string) CompleteMultipartUploadResponse
GenerateCompleteMultipartUploadResponse
func GenerateCopyObjectResponse ¶
GenerateCopyObjectResponse
func GenerateInitiateMultipartUploadResponse ¶
func GenerateInitiateMultipartUploadResponse(bucket, key, uploadID string) InitiateMultipartUploadResponse
GenerateInitiateMultipartUploadResponse
func GenerateListBucketsResponse ¶
func GenerateListBucketsResponse(buckets []meta.Bucket, credential iam.Credential) ListBucketsResponse
Takes an array of Bucket metadata information for serialization input: array of bucket metadata output: populated struct that can be serialized to match xml and json api spec output
func GenerateListObjectsResponse ¶
func GenerateListObjectsResponse(bucketName string, request ListObjectsRequest, objectsInfo meta.ListObjectsInfo) (response ListObjectsResponse)
generates an ListObjects response for the said bucket with other enumerated options.
func GenerateVersionedListObjectResponse ¶
func GenerateVersionedListObjectResponse(bucketName string, request ListObjectsRequest, objectsInfo meta.VersionedListObjectsInfo) (response VersionedListObjectsResponse)
func GetObjectLocation ¶
getObjectLocation gets the relative URL for an object
func InReservedOrigins ¶
func RegisterAPIRouter ¶
func RegisterAPIRouter(mux *router.Router, api ObjectAPIHandlers)
registerAPIRouter - registers S3 compatible APIs.
func RegisterHandlers ¶
func RegisterHandlers(router *mux.Router, objectLayer ObjectLayer, handlerFns ...HandlerFunc) http.Handler
func SetAuthHandler ¶ added in v1.1.0
func SetAuthHandler(h http.Handler, _ ObjectLayer) http.Handler
setAuthHandler to validate authorization header for the incoming request.
func SetCommonHeaderHandler ¶
func SetCommonHeaderHandler(h http.Handler, _ ObjectLayer) http.Handler
func SetCorsHandler ¶
func SetCorsHandler(h http.Handler, objectLayer ObjectLayer) http.Handler
setCorsHandler handler for CORS (Cross Origin Resource Sharing)
func SetIgnoreResourcesHandler ¶
func SetIgnoreResourcesHandler(h http.Handler, _ ObjectLayer) http.Handler
setIgnoreResourcesHandler - Ignore resources handler is wrapper handler used for API request resource validation Since we do not support all the S3 queries, it is necessary for us to throw back a valid error message indicating that requested feature is not implemented.
func SetLogHandler ¶
func SetLogHandler(handler http.Handler, _ ObjectLayer) http.Handler
func SetObjectHeaders ¶
func SetObjectHeaders(w http.ResponseWriter, object *meta.Object, contentRange *HttpRange)
Write object header
func SetRateLimitHandler ¶ added in v1.1.0
func SetRateLimitHandler(handler http.Handler, _ ObjectLayer) http.Handler
setRateLimitHandler limits the number of concurrent http requests based on CONFIG.ConcurrentRequestLimit
func WriteErrorResponse ¶
func WriteErrorResponse(w http.ResponseWriter, r *http.Request, err error)
writeErrorResponse write error headers
func WriteErrorResponseHeaders ¶
func WriteErrorResponseHeaders(w http.ResponseWriter, err error)
func WriteSuccessNoContent ¶
func WriteSuccessNoContent(w http.ResponseWriter)
writeSuccessNoContent write success headers with http status 204
func WriteSuccessResponse ¶
func WriteSuccessResponse(w http.ResponseWriter, response []byte)
WriteSuccessResponse write success headers and response if any.
Types ¶
type ApiErrorResponse ¶
type ApiErrorResponse struct { XMLName xml.Name `xml:"Error" json:"-"` AwsErrorCode string `xml:"Code"` Message string Key string BucketName string Resource string RequestId string HostId string }
APIErrorResponse - error response format
type AuthHandler ¶ added in v1.1.0
type AuthHandler struct {
// contains filtered or unexported fields
}
authHandler - handles all the incoming authorization headers and validates them if possible.
func (AuthHandler) ServeHTTP ¶ added in v1.1.0
func (a AuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
handler for validating incoming authorization headers.
type DeleteObjectsResponse ¶
type DeleteObjectsResponse struct { XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ DeleteResult" json:"-"` // Collection of all deleted objects DeletedObjects []ObjectIdentifier `xml:"Deleted,omitempty"` // Collection of errors deleting certain objects. Errors []DeleteError `xml:"Error,omitempty"` }
DeleteObjectsResponse container for multiple object deletes.
func GenerateMultiDeleteResponse ¶
func GenerateMultiDeleteResponse(quiet bool, deletedObjects []ObjectIdentifier, errs []DeleteError) DeleteObjectsResponse
generate multi objects delete response.
type HandlerFunc ¶
type HandlerFunc func(http.Handler, ObjectLayer) http.Handler
HandlerFunc - useful to chain different middleware http.Handler
type ObjectAPIHandlers ¶
type ObjectAPIHandlers struct {
ObjectAPI ObjectLayer
}
objectAPIHandler implements and provides http handlers for S3 API.
func (ObjectAPIHandlers) AbortMultipartUploadHandler ¶
func (api ObjectAPIHandlers) AbortMultipartUploadHandler(w http.ResponseWriter, r *http.Request)
AbortMultipartUploadHandler - Abort multipart upload
func (ObjectAPIHandlers) CompleteMultipartUploadHandler ¶
func (api ObjectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWriter, r *http.Request)
CompleteMultipartUploadHandler - Complete multipart upload
func (ObjectAPIHandlers) CopyObjectHandler ¶
func (api ObjectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Request)
CopyObjectHandler - Copy Object ---------- This implementation of the PUT operation adds an object to a bucket while reading the object from another source.
func (ObjectAPIHandlers) CopyObjectPartHandler ¶
func (api ObjectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *http.Request)
Upload part - copy
func (ObjectAPIHandlers) DelBucketLifeCycleHandler ¶
func (api ObjectAPIHandlers) DelBucketLifeCycleHandler(w http.ResponseWriter, r *http.Request)
func (ObjectAPIHandlers) DeleteBucketCorsHandler ¶
func (api ObjectAPIHandlers) DeleteBucketCorsHandler(w http.ResponseWriter, r *http.Request)
func (ObjectAPIHandlers) DeleteBucketHandler ¶
func (api ObjectAPIHandlers) DeleteBucketHandler(w http.ResponseWriter, r *http.Request)
DeleteBucketHandler - Delete bucket
func (ObjectAPIHandlers) DeleteMultipleObjectsHandler ¶
func (api ObjectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *http.Request)
DeleteMultipleObjectsHandler - deletes multiple objects.
func (ObjectAPIHandlers) DeleteObjectHandler ¶
func (api ObjectAPIHandlers) DeleteObjectHandler(w http.ResponseWriter, r *http.Request)
DeleteObjectHandler - delete an object
func (ObjectAPIHandlers) GetBucketAclHandler ¶
func (api ObjectAPIHandlers) GetBucketAclHandler(w http.ResponseWriter, r *http.Request)
func (ObjectAPIHandlers) GetBucketCorsHandler ¶
func (api ObjectAPIHandlers) GetBucketCorsHandler(w http.ResponseWriter, r *http.Request)
func (ObjectAPIHandlers) GetBucketLifeCycleHandler ¶
func (api ObjectAPIHandlers) GetBucketLifeCycleHandler(w http.ResponseWriter, r *http.Request)
func (ObjectAPIHandlers) GetBucketLocationHandler ¶
func (api ObjectAPIHandlers) GetBucketLocationHandler(w http.ResponseWriter, r *http.Request)
GetBucketLocationHandler - GET Bucket location. ------------------------- This operation returns bucket location.
func (ObjectAPIHandlers) GetBucketPolicyHandler ¶
func (api ObjectAPIHandlers) GetBucketPolicyHandler(w http.ResponseWriter, r *http.Request)
func (ObjectAPIHandlers) GetBucketVersioningHandler ¶
func (api ObjectAPIHandlers) GetBucketVersioningHandler(w http.ResponseWriter, r *http.Request)
func (ObjectAPIHandlers) GetObjectAclHandler ¶
func (api ObjectAPIHandlers) GetObjectAclHandler(w http.ResponseWriter, r *http.Request)
func (ObjectAPIHandlers) GetObjectHandler ¶
func (api ObjectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Request)
GetObjectHandler - GET Object ---------- This implementation of the GET operation retrieves object. To use GET, you must have READ access to the object.
func (ObjectAPIHandlers) HeadBucketHandler ¶
func (api ObjectAPIHandlers) HeadBucketHandler(w http.ResponseWriter, r *http.Request)
HeadBucketHandler - HEAD Bucket ---------- This operation is useful to determine if a bucket exists. The operation returns a 200 OK if the bucket exists and you have permission to access it. Otherwise, the operation might return responses such as 404 Not Found and 403 Forbidden.
func (ObjectAPIHandlers) HeadObjectHandler ¶
func (api ObjectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Request)
HeadObjectHandler - HEAD Object ----------- The HEAD operation retrieves metadata from an object without returning the object itself. TODO refactor HEAD and GET
func (ObjectAPIHandlers) ListBucketsHandler ¶
func (api ObjectAPIHandlers) ListBucketsHandler(w http.ResponseWriter, r *http.Request)
ListBucketsHandler - GET Service ----------- This implementation of the GET operation returns a list of all buckets owned by the authenticated sender of the request.
func (ObjectAPIHandlers) ListMultipartUploadsHandler ¶
func (api ObjectAPIHandlers) ListMultipartUploadsHandler(w http.ResponseWriter, r *http.Request)
ListMultipartUploadsHandler - GET Bucket (List Multipart uploads) ------------------------- This operation lists in-progress multipart uploads. An in-progress multipart upload is a multipart upload that has been initiated, using the Initiate Multipart Upload request, but has not yet been completed or aborted. This operation returns at most 1,000 multipart uploads in the response.
func (ObjectAPIHandlers) ListObjectPartsHandler ¶
func (api ObjectAPIHandlers) ListObjectPartsHandler(w http.ResponseWriter, r *http.Request)
ListObjectPartsHandler - List object parts
func (ObjectAPIHandlers) ListObjectsHandler ¶
func (api ObjectAPIHandlers) ListObjectsHandler(w http.ResponseWriter, r *http.Request)
ListObjectsHandler - GET Bucket (List Objects) -- ----------------------- This implementation of the GET operation returns some or all (up to 1000) of the objects in a bucket. You can use the request parameters as selection criteria to return a subset of the objects in a bucket.
func (ObjectAPIHandlers) ListVersionedObjectsHandler ¶
func (api ObjectAPIHandlers) ListVersionedObjectsHandler(w http.ResponseWriter, r *http.Request)
func (ObjectAPIHandlers) NewMultipartUploadHandler ¶
func (api ObjectAPIHandlers) NewMultipartUploadHandler(w http.ResponseWriter, r *http.Request)
NewMultipartUploadHandler - New multipart upload
func (ObjectAPIHandlers) PostPolicyBucketHandler ¶ added in v1.1.0
func (api ObjectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *http.Request)
func (ObjectAPIHandlers) PutBucketAclHandler ¶
func (api ObjectAPIHandlers) PutBucketAclHandler(w http.ResponseWriter, r *http.Request)
func (ObjectAPIHandlers) PutBucketCorsHandler ¶
func (api ObjectAPIHandlers) PutBucketCorsHandler(w http.ResponseWriter, r *http.Request)
func (ObjectAPIHandlers) PutBucketHandler ¶
func (api ObjectAPIHandlers) PutBucketHandler(w http.ResponseWriter, r *http.Request)
PutBucketHandler - PUT Bucket ---------- This implementation of the PUT operation creates a new bucket for authenticated request
func (ObjectAPIHandlers) PutBucketLifeCycleHandler ¶
func (api ObjectAPIHandlers) PutBucketLifeCycleHandler(w http.ResponseWriter, r *http.Request)
func (ObjectAPIHandlers) PutBucketVersioningHandler ¶
func (api ObjectAPIHandlers) PutBucketVersioningHandler(w http.ResponseWriter, r *http.Request)
func (ObjectAPIHandlers) PutObjectAclHandler ¶
func (api ObjectAPIHandlers) PutObjectAclHandler(w http.ResponseWriter, r *http.Request)
func (ObjectAPIHandlers) PutObjectHandler ¶
func (api ObjectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Request)
PutObjectHandler - PUT Object ---------- This implementation of the PUT operation adds an object to a bucket.
func (ObjectAPIHandlers) PutObjectPartHandler ¶
func (api ObjectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http.Request)
PutObjectPartHandler - Upload part
type ObjectLayer ¶
type ObjectLayer interface { // Bucket operations. MakeBucket(bucket string, acl datatype.Acl, credential iam.Credential) error SetBucketLc(bucket string, config datatype.Lc, credential iam.Credential) error GetBucketLc(bucket string, credential iam.Credential) (datatype.Lc, error) DelBucketLc(bucket string, credential iam.Credential) error SetBucketAcl(bucket string, policy datatype.AccessControlPolicy, acl datatype.Acl, credential iam.Credential) error GetBucketAcl(bucket string, credential iam.Credential) (datatype.AccessControlPolicy, error) SetBucketCors(bucket string, cors datatype.Cors, credential iam.Credential) error SetBucketVersioning(bucket string, versioning datatype.Versioning, credential iam.Credential) error DeleteBucketCors(bucket string, credential iam.Credential) error GetBucketVersioning(bucket string, credential iam.Credential) (datatype.Versioning, error) GetBucketCors(bucket string, credential iam.Credential) (datatype.Cors, error) GetBucket(bucketName string) (bucket meta.Bucket, err error) // For INTERNAL USE ONLY GetBucketInfo(bucket string, credential iam.Credential) (bucketInfo meta.Bucket, err error) ListBuckets(credential iam.Credential) (buckets []meta.Bucket, err error) DeleteBucket(bucket string, credential iam.Credential) error ListObjects(credential iam.Credential, bucket string, request datatype.ListObjectsRequest) (result meta.ListObjectsInfo, err error) ListVersionedObjects(credential iam.Credential, bucket string, request datatype.ListObjectsRequest) (result meta.VersionedListObjectsInfo, err error) // Object operations. GetObject(object *meta.Object, startOffset int64, length int64, writer io.Writer, sse datatype.SseRequest) (err error) GetObjectInfo(bucket, object, version string, credential iam.Credential) (objInfo *meta.Object, err error) PutObject(bucket, object string, credential iam.Credential, size int64, data io.Reader, metadata map[string]string, acl datatype.Acl, sse datatype.SseRequest) (result datatype.PutObjectResult, err error) CopyObject(targetObject *meta.Object, source io.Reader, credential iam.Credential, sse datatype.SseRequest) (result datatype.PutObjectResult, err error) SetObjectAcl(bucket string, object string, version string, policy datatype.AccessControlPolicy, acl datatype.Acl, credential iam.Credential) error GetObjectAcl(bucket string, object string, version string, credential iam.Credential) ( policy datatype.AccessControlPolicy, err error) DeleteObject(bucket, object, version string, credential iam.Credential) (datatype.DeleteObjectResult, error) // Multipart operations. ListMultipartUploads(credential iam.Credential, bucket string, request datatype.ListUploadsRequest) (result datatype.ListMultipartUploadsResponse, err error) NewMultipartUpload(credential iam.Credential, bucket, object string, metadata map[string]string, acl datatype.Acl, sse datatype.SseRequest) (uploadID string, err error) PutObjectPart(bucket, object string, credential iam.Credential, uploadID string, partID int, size int64, data io.Reader, md5Hex string, sse datatype.SseRequest) (result datatype.PutObjectPartResult, err error) CopyObjectPart(bucketName, objectName, uploadId string, partId int, size int64, data io.Reader, credential iam.Credential, sse datatype.SseRequest) (result datatype.PutObjectResult, err error) ListObjectParts(credential iam.Credential, bucket, object string, request datatype.ListPartsRequest) (result datatype.ListPartsResponse, err error) AbortMultipartUpload(credential iam.Credential, bucket, object, uploadID string) error CompleteMultipartUpload(credential iam.Credential, bucket, object, uploadID string, uploadedParts []meta.CompletePart) (result datatype.CompleteMultipartResult, err error) }
ObjectLayer implements primitives for object API layer.