github.com/aavshr/aws-sdk-go@v1.41.3/service/s3/customizations.go (about)

     1  package s3
     2  
     3  import (
     4  	"github.com/aavshr/aws-sdk-go/aws/client"
     5  	"github.com/aavshr/aws-sdk-go/aws/request"
     6  	"github.com/aavshr/aws-sdk-go/internal/s3shared/arn"
     7  	"github.com/aavshr/aws-sdk-go/internal/s3shared/s3err"
     8  )
     9  
    10  func init() {
    11  	initClient = defaultInitClientFn
    12  	initRequest = defaultInitRequestFn
    13  }
    14  
    15  func defaultInitClientFn(c *client.Client) {
    16  	// Support building custom endpoints based on config
    17  	c.Handlers.Build.PushFront(endpointHandler)
    18  
    19  	// Require SSL when using SSE keys
    20  	c.Handlers.Validate.PushBack(validateSSERequiresSSL)
    21  	c.Handlers.Build.PushBack(computeSSEKeyMD5)
    22  	c.Handlers.Build.PushBack(computeCopySourceSSEKeyMD5)
    23  
    24  	// S3 uses custom error unmarshaling logic
    25  	c.Handlers.UnmarshalError.Clear()
    26  	c.Handlers.UnmarshalError.PushBack(unmarshalError)
    27  	c.Handlers.UnmarshalError.PushBackNamed(s3err.RequestFailureWrapperHandler())
    28  }
    29  
    30  func defaultInitRequestFn(r *request.Request) {
    31  	// Add request handlers for specific platforms.
    32  	// e.g. 100-continue support for PUT requests using Go 1.6
    33  	platformRequestHandlers(r)
    34  
    35  	switch r.Operation.Name {
    36  	case opGetBucketLocation:
    37  		// GetBucketLocation has custom parsing logic
    38  		r.Handlers.Unmarshal.PushFront(buildGetBucketLocation)
    39  	case opCreateBucket:
    40  		// Auto-populate LocationConstraint with current region
    41  		r.Handlers.Validate.PushFront(populateLocationConstraint)
    42  	case opCopyObject, opUploadPartCopy, opCompleteMultipartUpload:
    43  		r.Handlers.Unmarshal.PushFront(copyMultipartStatusOKUnmarshalError)
    44  		r.Handlers.Unmarshal.PushBackNamed(s3err.RequestFailureWrapperHandler())
    45  	case opPutObject, opUploadPart:
    46  		r.Handlers.Build.PushBack(computeBodyHashes)
    47  		// Disabled until #1837 root issue is resolved.
    48  		//	case opGetObject:
    49  		//		r.Handlers.Build.PushBack(askForTxEncodingAppendMD5)
    50  		//		r.Handlers.Unmarshal.PushBack(useMD5ValidationReader)
    51  	case opWriteGetObjectResponse:
    52  		r.Handlers.Build.PushFront(buildWriteGetObjectResponseEndpoint)
    53  	}
    54  }
    55  
    56  // bucketGetter is an accessor interface to grab the "Bucket" field from
    57  // an S3 type.
    58  type bucketGetter interface {
    59  	getBucket() string
    60  }
    61  
    62  // sseCustomerKeyGetter is an accessor interface to grab the "SSECustomerKey"
    63  // field from an S3 type.
    64  type sseCustomerKeyGetter interface {
    65  	getSSECustomerKey() string
    66  }
    67  
    68  // copySourceSSECustomerKeyGetter is an accessor interface to grab the
    69  // "CopySourceSSECustomerKey" field from an S3 type.
    70  type copySourceSSECustomerKeyGetter interface {
    71  	getCopySourceSSECustomerKey() string
    72  }
    73  
    74  // endpointARNGetter is an accessor interface to grab the
    75  // the field corresponding to an endpoint ARN input.
    76  type endpointARNGetter interface {
    77  	getEndpointARN() (arn.Resource, error)
    78  	hasEndpointARN() bool
    79  }