another question: is it possible to use Config4k (...
# ktor
e
another question: is it possible to use Config4k (https://github.com/config4k/config4k) with ktor? I didn’t find any way to access the underlying
com.typesafe.config.Config
object, am I missing something?
r
I ran into that, too, wanted to use some advanced Config features and was frustrated to find that we can't access it directly. This is what I ended up doing:
Copy code
fun ApplicationConfig.getHoconConfig(): Config {
    require(this is HoconApplicationConfig)
    val internalConfigField = HoconApplicationConfig::class.java.getDeclaredField("config")
    internalConfigField.isAccessible = true
    return internalConfigField.get(this) as Config
}
I just call that function when starting the server to retrieve the actual config, works fine so far.
e
yeah, I was thinking about using reflection as well. I wanted to just recreate the
Config
object similar to how it’s done in
CommandLine.kt
, but again, I have a hard time accessing the arguments the application was started with 😐