Skip to content

Commit 120f7e6

Browse files
committed
Make sure APIGatewayProxyResponseEvent gets a mutable header map
1 parent 23eee82 commit 120f7e6

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

router/src/main/kotlin/io/moia/router/RequestHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ abstract class RequestHandler : RequestHandler<APIGatewayProxyRequestEvent, APIG
204204
}.let { finalContentType ->
205205
APIGatewayProxyResponseEvent()
206206
.withStatusCode(response.statusCode)
207-
.withHeaders(response.headers + ("Content-Type" to finalContentType.toString()))
207+
.withHeaders(response.headers.toMutableMap().apply { put("Content-Type", finalContentType.toString()) })
208208
.withBody(response.body?.let {
209209
serializationHandlerChain.serialize(finalContentType, it as Any)
210210
})

router/src/test/kotlin/io/moia/router/RequestHandlerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ class RequestHandlerTest {
539539
private val incrementingFilter = Filter { next ->
540540
{ request ->
541541
filterInvocations += 1
542-
next(request).apply { headers = headers + ("header" to "value") }
542+
next(request).apply { withHeader("header", "value") }
543543
}
544544
}
545545
override val router = router {

0 commit comments

Comments
 (0)