context.go (1646B)
1 package context 2 3 import ( 4 "context" 5 "time" 6 7 "github.com/aws/smithy-go/middleware" 8 ) 9 10 type s3BackendKey struct{} 11 type checksumInputAlgorithmKey struct{} 12 type clockSkew struct{} 13 14 const ( 15 // S3BackendS3Express identifies the S3Express backend 16 S3BackendS3Express = "S3Express" 17 ) 18 19 // SetS3Backend stores the resolved endpoint backend within the request 20 // context, which is required for a variety of custom S3 behaviors. 21 func SetS3Backend(ctx context.Context, typ string) context.Context { 22 return middleware.WithStackValue(ctx, s3BackendKey{}, typ) 23 } 24 25 // GetS3Backend retrieves the stored endpoint backend within the context. 26 func GetS3Backend(ctx context.Context) string { 27 v, _ := middleware.GetStackValue(ctx, s3BackendKey{}).(string) 28 return v 29 } 30 31 // SetChecksumInputAlgorithm sets the request checksum algorithm on the 32 // context. 33 func SetChecksumInputAlgorithm(ctx context.Context, value string) context.Context { 34 return middleware.WithStackValue(ctx, checksumInputAlgorithmKey{}, value) 35 } 36 37 // GetChecksumInputAlgorithm returns the checksum algorithm from the context. 38 func GetChecksumInputAlgorithm(ctx context.Context) string { 39 v, _ := middleware.GetStackValue(ctx, checksumInputAlgorithmKey{}).(string) 40 return v 41 } 42 43 // SetAttemptSkewContext sets the clock skew value on the context 44 func SetAttemptSkewContext(ctx context.Context, v time.Duration) context.Context { 45 return middleware.WithStackValue(ctx, clockSkew{}, v) 46 } 47 48 // GetAttemptSkewContext gets the clock skew value from the context 49 func GetAttemptSkewContext(ctx context.Context) time.Duration { 50 x, _ := middleware.GetStackValue(ctx, clockSkew{}).(time.Duration) 51 return x 52 }