On another note regarding environment/lenses. I’m ...
# http4k
r
On another note regarding environment/lenses. I’m wondering if it would just be possible to define a single data class that you give environment instead of many lenses, one for each of the variables it will collect. Example:
Copy code
val servicePort: Int
private val servicePortLens = <http://EnvironmentKey.int|EnvironmentKey.int>().required("SERVICE_PORT")

val healthPort: Int
private val healthPortLens = <http://EnvironmentKey.int|EnvironmentKey.int>().required("HEALTH_PORT")
....
Other lenses/variables
...
servicePort = environment[servicePortLens]
healthPort = environment[healthPortLens]
...
Other variable assignments from lenses.
Couldn’t it be just:
Copy code
data class Config(val servicePort: Int, val healthPort: Int, ...)
val config = environment[configLens]