All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.http4k.format.cloudEventsExtensions.kt Maven / Gradle / Ivy

The newest version!
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