https://kotlinlang.org logo
#ktor
Title
# ktor
s

Shawn A

07/06/2020, 4:00 PM
How does one handle custom config binding from the app's HOCON? I've read the configuration docs but its not quite clear if/how I can bind arbitrary config values to, for instance a data class.
👀 1
m

mp

07/06/2020, 6:42 PM
IMO ktor's whole config thing is misguided. Do config however you want, and then call
embeddedServer
as you see fit.
For one way to do it, I keep https://bitbucket.org/marshallpierce/ktor-demo/src/master/ around to show such things, but the point is you don't need to use ktor's hocon thing at all.
w

Wilfred

07/07/2020, 12:28 PM
Going with the example here; https://ktor.io/servers/configuration/environments.html You could also initialize a data class, mapping it’s properties to the config values in the environment config
s

Shawn A

07/08/2020, 2:26 PM
Thanks for the insight @mp @Wilfred. I too felt a bit meh after reading how ktor is using HOCON.
👍 1