<@U6QF4BK4H> you could try something like this: ``...
# http4k
d
@joscha.alisch you could try something like this:
Copy code
import org.http4k.cloudnative.env.Environment
import org.http4k.cloudnative.env.EnvironmentKey
import org.http4k.lens.LensGet
import org.http4k.lens.LensSpec
import org.http4k.lens.ParamMeta.ObjectParam
import <http://org.http4k.lens.int|org.http4k.lens.int>

data class MyThing(val a: Int, val b: String)

inline fun <reified T> compositeLens(crossinline fn: EnvironmentKey.(Environment) -> T) = LensSpec<Environment, T>(
    T::class.java.name, ObjectParam, LensGet { _, target -> listOf(EnvironmentKey.fn(target)) }).required(T::class.java.name)

fun main() {
    val lens = compositeLens { MyThing(int().required("FOO")(it), required("VAR")(it)) }
    lens(Environment.EMPTY)
}