@@ -56,7 +56,8 @@ func (m DbEsdkMiddleware) createRequestInterceptor() middleware.InitializeMiddle
56
56
57
57
// handleRequestInterception handles the interception logic before the DynamoDB operation
58
58
func (m DbEsdkMiddleware ) handleRequestInterception (ctx context.Context , params interface {}) context.Context {
59
- if v , ok := params .(* dynamodb.PutItemInput ); ok {
59
+ switch v := params .(type ) {
60
+ case * dynamodb.PutItemInput :
60
61
ctx = middleware .WithStackValue (ctx , "originalInput" , * DeepCopyPutItemInput (v ))
61
62
transformedRequest , err := m .client .PutItemInputTransform (context .TODO (), awscryptographydbencryptionsdkdynamodbtransformssmithygeneratedtypes.PutItemInputTransformInput {
62
63
SdkInput : * v ,
@@ -65,8 +66,7 @@ func (m DbEsdkMiddleware) handleRequestInterception(ctx context.Context, params
65
66
fmt .Println (err )
66
67
}
67
68
* v = transformedRequest .TransformedInput
68
- }
69
- if v , ok := params .(* dynamodb.GetItemInput ); ok {
69
+ case * dynamodb.GetItemInput :
70
70
ctx = middleware .WithStackValue (ctx , "originalInput" , * DeepCopyGetItemInput (v ))
71
71
transformedRequest , err := m .client .GetItemInputTransform (context .TODO (), awscryptographydbencryptionsdkdynamodbtransformssmithygeneratedtypes.GetItemInputTransformInput {
72
72
SdkInput : * v ,
@@ -75,15 +75,8 @@ func (m DbEsdkMiddleware) handleRequestInterception(ctx context.Context, params
75
75
fmt .Println (err )
76
76
}
77
77
* v = transformedRequest .TransformedInput
78
- }
79
- if v , ok := params .(* dynamodb.BatchExecuteStatementInput ); ok {
80
- BatchExecuteStatementInputTransformOutput , err := m .client .BatchExecuteStatementInputTransform (context .TODO (), awscryptographydbencryptionsdkdynamodbtransformssmithygeneratedtypes.BatchExecuteStatementInputTransformInput {
81
- SdkInput : * v ,
82
- })
83
- if err != nil {
84
- fmt .Println (err )
85
- }
86
- * v = BatchExecuteStatementInputTransformOutput .TransformedInput
78
+ // case *dynamodb.BatchExecuteStatementInput:
79
+ // m.originalRequests["BatchExecuteStatementInput"] = *DeepCopyBatchExecuteStatementInput(v)
87
80
}
88
81
return ctx
89
82
}
@@ -108,7 +101,8 @@ func (m DbEsdkMiddleware) createResponseInterceptor() middleware.FinalizeMiddlew
108
101
109
102
// handleResponseInterception handles the interception logic after the DynamoDB operation
110
103
func (m DbEsdkMiddleware ) handleResponseInterception (ctx context.Context , response interface {}) {
111
- if v , ok := response .(* dynamodb.PutItemOutput ); ok {
104
+ switch v := response .(type ) {
105
+ case * dynamodb.PutItemOutput :
112
106
transformedRequest , err := m .client .PutItemOutputTransform (context .TODO (), awscryptographydbencryptionsdkdynamodbtransformssmithygeneratedtypes.PutItemOutputTransformInput {
113
107
OriginalInput : middleware .GetStackValue (ctx , "originalInput" ).(dynamodb.PutItemInput ),
114
108
SdkOutput : * v ,
@@ -117,8 +111,7 @@ func (m DbEsdkMiddleware) handleResponseInterception(ctx context.Context, respon
117
111
fmt .Println (err )
118
112
}
119
113
* v = transformedRequest .TransformedOutput
120
- }
121
- if v , ok := response .(* dynamodb.GetItemOutput ); ok {
114
+ case * dynamodb.GetItemOutput :
122
115
transformedRequest , err := m .client .GetItemOutputTransform (context .TODO (), awscryptographydbencryptionsdkdynamodbtransformssmithygeneratedtypes.GetItemOutputTransformInput {
123
116
OriginalInput : middleware .GetStackValue (ctx , "originalInput" ).(dynamodb.GetItemInput ),
124
117
SdkOutput : * v ,
@@ -128,23 +121,7 @@ func (m DbEsdkMiddleware) handleResponseInterception(ctx context.Context, respon
128
121
}
129
122
* v = transformedRequest .TransformedOutput
130
123
}
131
- // if getItemOutput, ok := response.(*dynamodb.GetItemOutput); ok {
132
- // fmt.Println("GetItemOutput Response intercepted:")
133
- // if age, ok := getItemOutput.Item["Age"].(*types.AttributeValueMemberN); ok {
134
- // fmt.Println("Age:", age.Value)
135
- // }
136
- // if id, ok := getItemOutput.Item["ID"].(*types.AttributeValueMemberN); ok {
137
- // fmt.Println("ID:", id.Value)
138
- // }
139
- // if name, ok := getItemOutput.Item["Name"].(*types.AttributeValueMemberS); ok {
140
- // fmt.Println("Name:", name.Value)
141
- // }
142
- // if intercepted, ok := getItemOutput.Item["intercepted attribute"].(*types.AttributeValueMemberS); ok {
143
- // fmt.Println("intercepted attribute:", intercepted.Value)
144
- // }
145
- // getItemOutput.Item["intercepted attribute"] = &types.AttributeValueMemberS{Value: "I read your data "}
146
- // // You can modify the response here if needed
147
- // }
124
+
148
125
}
149
126
150
127
// DeepCopyPutItemInput performs a deep copy of a PutItemInput struct.
0 commit comments