Hey folks :slightly_smiling_face: What would be yo...
# http4k
j
Hey folks 🙂 What would be your recommended way of creating an environment config from multiple `EnvironmentKey`s ? Say I want to create an instance of
data class MongoDBSettings(val host: String, val port: Int)
from the environment variables
MONGO_HOST
and
MONGO_PORT
. Would I have them as separate `EnvironmentKey`s and do the mapping outside or is there some lens magic where I can do something like
EnvironmentKey.mongoSettings().required("MONGO_HOST", "MONGO_PORT")
?
s
@joscha.alisch right now the only option is individual keys. They can be composed to build your settings object inside any normal function (standalone, extension, or companion). My personal preference is to have extensions to Environment to do this extraction of more complex structures.