enhance api for ConditionalHeaders usage
See original GitHub issuesorry if there is already an appropriate way of doing this what I’m going to ask for. Since the documentation is lacking with respect to the usage of the ConditionalHeaders
feature I coulnd’t find a way of managing it concisely.
As far as I could see, in order to utilize ConditionalHeaders
the OutgoingContent
’s headers need to be set. Thus this here
// somewhere in installation phase
install(ContentNegotiation) {
register(ContentType.Application.Json, GsonConverter())
}
install(ConditionalHeaders)
// somewhere in api call
ctx.call.response.header(HttpHeaders.LastModified, lastModifiedTime)
ctx.call.respond(HttpStatusCode.OK, anydata)
don’t have any effect since the header of the ApplicationResponse is set (instead of the content).
Therefore when I use ContentNegotiation
I would need to adapt the conversion process so that the produced OutgoingContent instances also contain the relevant headers which is imho against the concise api nature of ktor.
wouldn’t it make sense that ApplicationResponse headers are applied to the OutgoingContent headers?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
I see only two options (we probably need both):
The second one is easy to implement while the first requires design
@soywiz it’s not documented btw, need to notice it here https://ktor.io/servers/features/conditional-headers.html