customizations.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package s3
  2. import (
  3. "github.com/aws/aws-sdk-go/aws/request"
  4. "github.com/aws/aws-sdk-go/aws/service"
  5. )
  6. func init() {
  7. initService = func(s *service.Service) {
  8. // Support building custom host-style bucket endpoints
  9. s.Handlers.Build.PushFront(updateHostWithBucket)
  10. // Require SSL when using SSE keys
  11. s.Handlers.Validate.PushBack(validateSSERequiresSSL)
  12. s.Handlers.Build.PushBack(computeSSEKeys)
  13. // S3 uses custom error unmarshaling logic
  14. s.Handlers.UnmarshalError.Clear()
  15. s.Handlers.UnmarshalError.PushBack(unmarshalError)
  16. }
  17. initRequest = func(r *request.Request) {
  18. switch r.Operation.Name {
  19. case opPutBucketCors, opPutBucketLifecycle, opPutBucketPolicy, opPutBucketTagging, opDeleteObjects:
  20. // These S3 operations require Content-MD5 to be set
  21. r.Handlers.Build.PushBack(contentMD5)
  22. case opGetBucketLocation:
  23. // GetBucketLocation has custom parsing logic
  24. r.Handlers.Unmarshal.PushFront(buildGetBucketLocation)
  25. case opCreateBucket:
  26. // Auto-populate LocationConstraint with current region
  27. r.Handlers.Validate.PushFront(populateLocationConstraint)
  28. }
  29. }
  30. }