https://kotlinlang.org logo
#ktor
Title
# ktor
m

mp

02/11/2019, 9:30 PM
Yep, when you post something to the test application engine, you now need to specify the content type
t

Tsvetozar Bonev

02/11/2019, 10:50 PM
Is there a way to define application/json as the default content-type now or do I have to specify it every time?
m

mkporwit

02/12/2019, 1:12 AM
It’s every time now.
😢 1
m

mp

02/12/2019, 12:39 PM
Write a helper extension function I suppose
t

Tsvetozar Bonev

02/12/2019, 1:53 PM
Can't see an easy way to do so when test methods already use functions that require knowledge of the test engine.
m

mp

02/12/2019, 1:57 PM
Instead of a
setBody
, write a
setJsonBody
that calls
setBody
and
addHeader
.
t

Tsvetozar Bonev

02/12/2019, 3:58 PM
I can do that yes, but I was more thinking of a way to have the setJsonBody be called by default.
I can't find this change listed as a breaking one, even thought it breaks every piece of code that hasn't explicitly set a content-type, which caused me some headache 😕
m

mp

02/12/2019, 4:22 PM
Indeed
2 Views