elifarley
03/06/2018, 9:46 PMclass SimpleObject(val id: String, val attrs: Map<String, Any?>,
val created: ZonedDateTime,
val updated: ZonedDateTime
)
If I use with( Header.zonedDateTime().required("last-modified") of obj.created)
, I end up with multiple attributes like "created":{"dateTime":{"date":{"year":2018,"month":3,...
).
I think it should be a single String attribute, based on my understanding of this.map(ZonedDateTime::parse, DateTimeFormatter.ISO_ZONED_DATE_TIME::format)
in file lensSpec.kts4nchez
03/06/2018, 9:49 PMJson
implementationelifarley
03/06/2018, 9:50 PMs4nchez
03/06/2018, 9:50 PMelifarley
03/06/2018, 9:51 PMs4nchez
03/06/2018, 9:58 PMimport org.http4k.core.Method
import org.http4k.core.Request
import org.http4k.core.with
import org.http4k.lens.Header
import org.http4k.lens.zonedDateTime
import java.time.ZonedDateTime
class SimpleObject(val id: String, val attrs: Map<String, Any?>,
val created: ZonedDateTime,
val updated: ZonedDateTime)
fun main(args: Array<String>) {
val obj = SimpleObject("foo", emptyMap(), ZonedDateTime.now(), ZonedDateTime.now())
val request = Request(Method.GET, "/")
.with(Header.zonedDateTime().required("last-modified") of obj.created)
println(request)
}
and got request = GET / HTTP/1.1
last-modified: 2018-03-06T21:56:51.882Z[Europe/London]
elifarley
03/06/2018, 10:00 PMcustomerService[id]?.let { obj ->
Response(OK).with(
bodySimpleObject of obj
).with(headerLastModified of obj.updated)
} ?: Response(Status.NOT_FOUND)
val headerLastModified = Header.zonedDateTime().required("last-modified")
s4nchez
03/06/2018, 10:05 PMHTTP/1.1 200 OK
content-type: application/json; charset=utf-8
last-modified: 2018-03-06T22:05:09.644Z[Europe/London]
{"id":"foo","attrs":{},"created":{"dateTime":{"date":{"year":2018,"month":3,"day":6},"time":{"hour":22,"minute":5,"second":9,"nano":644000000}},"offset":{"totalSeconds":0},"zone":{"id":"Europe/London"}},"updated":{"dateTime":{"date":{"year":2018,"month":3,"day":6},"time":{"hour":22,"minute":5,"second":9,"nano":717000000}},"offset":{"totalSeconds":0},"zone":{"id":"Europe/London"}}}
elifarley
03/06/2018, 10:06 PM2018-03-06T21:56:51.882Z[Europe/London]
?s4nchez
03/06/2018, 10:06 PMZonedDateTimes
. We're using a very vanilla configelifarley
03/06/2018, 10:06 PMs4nchez
03/06/2018, 10:08 PMelifarley
03/06/2018, 10:10 PMs4nchez
03/06/2018, 10:15 PMelifarley
03/06/2018, 10:17 PMs4nchez
03/06/2018, 10:19 PMelifarley
03/06/2018, 10:20 PM