org.http4k.format.cloudEventsExtensions.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http4k-cloudevents Show documentation
Show all versions of http4k-cloudevents Show documentation
http4k support for the CloudEvents format
package org.http4k.format
import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
import io.cloudevents.CloudEvent
import io.cloudevents.jackson.PojoCloudEventDataMapper
import org.http4k.lens.Lens
import org.http4k.lens.LensGet
import org.http4k.lens.LensSpec
import org.http4k.lens.ParamMeta.ObjectParam
inline fun ConfigurableJackson.cloudEventDataLens(): Lens {
val get = LensGet { _, target ->
target.data?.let { listOf(PojoCloudEventDataMapper.from(mapper, jacksonTypeRef()).map(it).value) }
.orEmpty()
}
return object : LensSpec("CloudEvent", ObjectParam, get) {}.required(T::class.simpleName!!)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy