Does anyone know of a way to get the built-in Cont...
# ktor
n
Does anyone know of a way to get the built-in ContentNegotiaion feature to use a default output converter for requests with no
Accept
header? I'm not seeing an obvious way to configure the module to use a default, and also have not been able to figure out a way to mutate / replace the request headers before the ContentNegotiation module looks at them to fake it out.
d
The ContentNegotiation uses the Accept, for other cases, you can use
call.respondText
and serialize it yourself
For example
call.respondText(ObjectMapper().writeValueAsString(obj), ContentType.Application.Json)
n
So if there's a possibility that a client will not send an Accept header, then using that module is not possible?
d
Right now. I think so.
n
That's a bummer. Is there any reason why it would be undesirable to treat an absent Accept header as
Accept: */*
d
I think there was a suggestion to allow to provide the content type from a get parameter, but I think it is not implemented
That doesn’t work?
I thought it was already like that
which ktor version are you using?
n
0.9.1
d
it was fixed in 0.9.2 as far as I remember
n
Cool, I'll check that out. Thanks!
d
“ContentNegotiation missing Accept header support (#317) ”
okay