@@ -17,10 +17,11 @@ import (
17
17
18
18
func addAPIRequestMiddleware (stack * middleware.Stack ,
19
19
options Options ,
20
+ operation string ,
20
21
getPath func (interface {}) (string , error ),
21
22
getOutput func (* smithyhttp.Response ) (interface {}, error ),
22
23
) (err error ) {
23
- err = addRequestMiddleware (stack , options , "GET" , getPath , getOutput )
24
+ err = addRequestMiddleware (stack , options , "GET" , operation , getPath , getOutput )
24
25
if err != nil {
25
26
return err
26
27
}
@@ -44,6 +45,7 @@ func addAPIRequestMiddleware(stack *middleware.Stack,
44
45
func addRequestMiddleware (stack * middleware.Stack ,
45
46
options Options ,
46
47
method string ,
48
+ operation string ,
47
49
getPath func (interface {}) (string , error ),
48
50
getOutput func (* smithyhttp.Response ) (interface {}, error ),
49
51
) (err error ) {
@@ -101,6 +103,10 @@ func addRequestMiddleware(stack *middleware.Stack,
101
103
return err
102
104
}
103
105
106
+ if err := addProtocolFinalizerMiddlewares (stack , options , operation ); err != nil {
107
+ return fmt .Errorf ("add protocol finalizers: %w" , err )
108
+ }
109
+
104
110
// Retry support
105
111
return retry .AddRetryMiddlewares (stack , retry.AddRetryMiddlewaresOptions {
106
112
Retryer : options .Retryer ,
@@ -283,3 +289,19 @@ func appendURIPath(base, add string) string {
283
289
}
284
290
return reqPath
285
291
}
292
+
293
+ func addProtocolFinalizerMiddlewares (stack * middleware.Stack , options Options , operation string ) error {
294
+ if err := stack .Finalize .Add (& resolveAuthSchemeMiddleware {operation : operation , options : options }, middleware .Before ); err != nil {
295
+ return fmt .Errorf ("add ResolveAuthScheme: %w" , err )
296
+ }
297
+ if err := stack .Finalize .Insert (& getIdentityMiddleware {options : options }, "ResolveAuthScheme" , middleware .After ); err != nil {
298
+ return fmt .Errorf ("add GetIdentity: %w" , err )
299
+ }
300
+ if err := stack .Finalize .Insert (& resolveEndpointV2Middleware {options : options }, "GetIdentity" , middleware .After ); err != nil {
301
+ return fmt .Errorf ("add ResolveEndpointV2: %w" , err )
302
+ }
303
+ if err := stack .Finalize .Insert (& signRequestMiddleware {}, "ResolveEndpointV2" , middleware .After ); err != nil {
304
+ return fmt .Errorf ("add Signing: %w" , err )
305
+ }
306
+ return nil
307
+ }
0 commit comments