Skip to content

Commit

Permalink
Add setting content-length middleware into operation stack
Browse files Browse the repository at this point in the history
Adds the ContentLengthMiddleware to the operation's stack, and updates
generated clients and protocol tests to use the content-length check.

Depends on:
* aws/smithy-go#108
* smithy-lang/smithy#491
  • Loading branch information
jasdel committed Jul 13, 2020
1 parent 4cb3d56 commit 85dda37
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Map;
import software.amazon.smithy.aws.traits.auth.SigV4Trait;
import software.amazon.smithy.aws.traits.auth.UnsignedPayloadTrait;
import software.amazon.smithy.go.codegen.SmithyGoDependency;
import software.amazon.smithy.go.codegen.SymbolUtils;
import software.amazon.smithy.go.codegen.integration.GoIntegration;
import software.amazon.smithy.go.codegen.integration.MiddlewareRegistrar;
Expand Down Expand Up @@ -43,6 +44,16 @@ public List<RuntimeClientPlugin> getClientPlugins() {
)
.build(),

// Add ContentLengthMiddleware to operation stack
RuntimeClientPlugin.builder()
.registerMiddleware(MiddlewareRegistrar.builder()
.resolvedFunction(SymbolUtils.createValueSymbolBuilder(
"AddContentLengthMiddleware", SmithyGoDependency.SMITHY_HTTP_TRANSPORT)
.build())
.build()
)
.build(),

// Add endpoint serialize middleware to operation stack
RuntimeClientPlugin.builder()
.registerMiddleware(MiddlewareRegistrar.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ public void generateProtocolTests(GenerationContext context) {
writer.addUseImports(SmithyGoDependency.SMITHY_MIDDLEWARE);
writer.openBlock("[]APIOptionFunc{", "},", () -> {
writer.openBlock("func(s *middleware.Stack) error {", "},", () -> {
writer.write("s.Build.Clear()");
writer.write("s.Finalize.Clear()");
writer.write("return nil");
});
Expand Down

0 comments on commit 85dda37

Please sign in to comment.