Hello! Ktor config can be accessed via environment...
# ktor
a
Hello! Ktor config can be accessed via environment.config. But this can only be done from a place where we have the environment in scope. So for example in a route, we can do call.application.environment. But how best to access config deep down in the business layer? Do we have to pass the config via parameters or is there another way? We tried by reading the .conf file ourselves with ConfigFactory.load. But this has the disadvantage that the config cannot be changed dynamically in integration tests as described here: https://ktor.io/docs/testing.html#map
i
What about to use a Koin library as Dependency Injection and inject your app config bean in service layers, like this ?
Copy code
val config: MyConfig by inject()
a
that MyConfig bean would still be dependent on the environment.config instance. maybe if it is possible to construct such a MyConfig bean on application startup where we can pass that in, that might work
a
Could you please explain why do you want to pass a server config to your business layer?
a
Not a server config, a business layer config. something like "calculationLookbackDays" for some accounting engine
a
Maybe you should store your business layer config separately from a server config.