Loading codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpProtocolGenerator.kt +15 −13 Original line number Diff line number Diff line Loading @@ -492,6 +492,21 @@ private class ServerHttpProtocolImplGenerator( * The `Content-Type` header is also set according to the protocol and the contents of the shape to be serialized. */ private fun RustWriter.serverRenderResponseHeaders(operationShape: OperationShape, errorShape: StructureShape? = null) { val bindingGenerator = ServerResponseBindingGenerator(protocol, codegenContext, operationShape) val addHeadersFn = bindingGenerator.generateAddHeadersFn(errorShape ?: operationShape) if (addHeadersFn != null) { // notice that we need to borrow the output only for output shapes but not for error shapes val outputOwnedOrBorrow = if (errorShape == null) "&output" else "output" rust( """ builder = #{T}($outputOwnedOrBorrow, builder)?; """.trimIndent(), addHeadersFn ) } // set the content type header *after* the response bindings headers have been set // to allow operations that bind a member to content-type to take precedence val contentType = httpBindingResolver.responseContentType(operationShape) if (contentType != null) { rustTemplate( Loading @@ -505,19 +520,6 @@ private class ServerHttpProtocolImplGenerator( *codegenScope ) } val bindingGenerator = ServerResponseBindingGenerator(protocol, codegenContext, operationShape) val addHeadersFn = bindingGenerator.generateAddHeadersFn(errorShape ?: operationShape) if (addHeadersFn != null) { // notice that we need to borrow the output only for output shapes but not for error shapes val outputOwnedOrBorrow = if (errorShape == null) "&output" else "output" rust( """ builder = #{T}($outputOwnedOrBorrow, builder)?; """.trimIndent(), addHeadersFn ) } } private fun serverRenderBindingSerializer( Loading Loading
codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpProtocolGenerator.kt +15 −13 Original line number Diff line number Diff line Loading @@ -492,6 +492,21 @@ private class ServerHttpProtocolImplGenerator( * The `Content-Type` header is also set according to the protocol and the contents of the shape to be serialized. */ private fun RustWriter.serverRenderResponseHeaders(operationShape: OperationShape, errorShape: StructureShape? = null) { val bindingGenerator = ServerResponseBindingGenerator(protocol, codegenContext, operationShape) val addHeadersFn = bindingGenerator.generateAddHeadersFn(errorShape ?: operationShape) if (addHeadersFn != null) { // notice that we need to borrow the output only for output shapes but not for error shapes val outputOwnedOrBorrow = if (errorShape == null) "&output" else "output" rust( """ builder = #{T}($outputOwnedOrBorrow, builder)?; """.trimIndent(), addHeadersFn ) } // set the content type header *after* the response bindings headers have been set // to allow operations that bind a member to content-type to take precedence val contentType = httpBindingResolver.responseContentType(operationShape) if (contentType != null) { rustTemplate( Loading @@ -505,19 +520,6 @@ private class ServerHttpProtocolImplGenerator( *codegenScope ) } val bindingGenerator = ServerResponseBindingGenerator(protocol, codegenContext, operationShape) val addHeadersFn = bindingGenerator.generateAddHeadersFn(errorShape ?: operationShape) if (addHeadersFn != null) { // notice that we need to borrow the output only for output shapes but not for error shapes val outputOwnedOrBorrow = if (errorShape == null) "&output" else "output" rust( """ builder = #{T}($outputOwnedOrBorrow, builder)?; """.trimIndent(), addHeadersFn ) } } private fun serverRenderBindingSerializer( Loading