From 48f1e2bc5845b37eaedcff12cefa6bc37d918c3c Mon Sep 17 00:00:00 2001 From: Lintterer Date: Mon, 29 Apr 2024 15:03:28 +0200 Subject: [PATCH] fix: using request content type as fallback --- .../de/innfactory/smithy4play/SmithyPlayEndpoint.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/smithy4play/src/main/scala/de/innfactory/smithy4play/SmithyPlayEndpoint.scala b/smithy4play/src/main/scala/de/innfactory/smithy4play/SmithyPlayEndpoint.scala index 8cd6f66b..962d01b8 100644 --- a/smithy4play/src/main/scala/de/innfactory/smithy4play/SmithyPlayEndpoint.scala +++ b/smithy4play/src/main/scala/de/innfactory/smithy4play/SmithyPlayEndpoint.scala @@ -64,10 +64,10 @@ class SmithyPlayEndpoint[Alg[_[_, _, _, _, _]], F[_] <: ContextRoute[_], Op[_, _ private def mapToEndpointResult( statusCode: Int - )(output: O): HttpResponse[Blob] = { + )(output: O)(implicit defaultContentType: ContentType): HttpResponse[Blob] = { val outputMetadata = outputMetadataEncoder.encode(output).headers.get(CaseInsensitive("content-type")) match { case Some(value) => value - case None => Seq(serviceContentType) + case None => Seq(defaultContentType.value) } codecDecider .httpMessageEncoder(outputMetadata) @@ -144,13 +144,13 @@ class SmithyPlayEndpoint[Alg[_[_, _, _, _, _]], F[_] <: ContextRoute[_], Op[_, _ .withHeaders(error.status.headers.toList: _*) .as(error.contentType) - private def handleSuccess(output: HttpResponse[Blob]): Result = { + private def handleSuccess(output: HttpResponse[Blob])(implicit defaultContentType: ContentType): Result = { val status = Results.Status(output.statusCode) val contentTypeKey = CaseInsensitive("content-type") val outputHeadersWithoutContentType = output.headers.-(contentTypeKey).toList.map(h => (h._1.toString, h._2.head)) val contentType = - output.headers.getOrElse(contentTypeKey, Seq(serviceContentType)) + output.headers.getOrElse(contentTypeKey, Seq(defaultContentType.value)) if (!output.body.isEmpty) { status(output.body.toArray)