From e8a6042a2215ace81892f9f98150eb6af4f9a86c Mon Sep 17 00:00:00 2001 From: Luc Talatinian Date: Wed, 8 Nov 2023 11:05:05 -0500 Subject: [PATCH] add inline finalize middleware gen --- .../GoStackStepMiddlewareGenerator.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/GoStackStepMiddlewareGenerator.java b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/GoStackStepMiddlewareGenerator.java index 0e6a6a572..87a087cdb 100644 --- a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/GoStackStepMiddlewareGenerator.java +++ b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/GoStackStepMiddlewareGenerator.java @@ -137,6 +137,28 @@ public static GoStackStepMiddlewareGenerator createFinalizeStepMiddleware(String SmithyGoTypes.Middleware.FinalizeHandler); } + /** + * Create an inline Finalize func. + * + * @param body is the function body. + * @return the generated middleware func. + */ + public static GoWriter.Writable generateFinalizeMiddlewareFunc(GoWriter.Writable body) { + return goTemplate(""" + func(ctx $T, in $T, next $T) ( + out $T, metadata $T, err error, + ) { + $W + } + """, + GoStdlibTypes.Context.Context, + SmithyGoTypes.Middleware.FinalizeInput, + SmithyGoTypes.Middleware.FinalizeHandler, + SmithyGoTypes.Middleware.FinalizeOutput, + SmithyGoTypes.Middleware.Metadata, + body); + } + /** * Create a new DeserializeStep middleware generator with the provided type name. *