Skip to content

Commit

Permalink
Made resolver a parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
0marperez committed Oct 12, 2023
1 parent 9227b7a commit 8e562e7
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,15 @@ abstract class HttpBindingProtocolGenerator : ProtocolGenerator {
writer.write("val payload = #T(context, input)", opBodySerializerFn)
writer.write("builder.body = #T.fromBytes(payload)", RuntimeTypes.Http.HttpBody)
}
renderContentTypeHeader(ctx, op, writer)
renderContentTypeHeader(ctx, op, writer, resolver)
}

protected open fun renderContentTypeHeader(ctx: ProtocolGenerator.GenerationContext, op: OperationShape, writer: KotlinWriter) {
val resolver = getProtocolHttpBindingResolver(ctx.model, ctx.service)
protected open fun renderContentTypeHeader(
ctx: ProtocolGenerator.GenerationContext,
op: OperationShape,
writer: KotlinWriter,
resolver: HttpBindingResolver = getProtocolHttpBindingResolver(ctx.model, ctx.service),
) {
resolver.determineRequestContentType(op)?.let { contentType ->
writer.withBlock("if (builder.body !is HttpBody.Empty) {", "}") {
write("builder.headers.setMissing(\"Content-Type\", #S)", contentType)
Expand Down

0 comments on commit 8e562e7

Please sign in to comment.