Does Typesafe Config allow to create conditional configurations?
I need to set a key depending on the value of another key:
ssl = true
#if ssl == true
host = "https://localhost"
#else
host = "http://localhost"
#end if
Of course the code above does't work... I just wanted to illustrate what I'm trying to do.
Not directly, no. For the particular example you gave, you could use optional properties:
protocol = "http"
protocol = ${?MY_PROTOCOL}
host = ${protocol}://localhost
Then if your application was started with either -Dprotocol=https as an argument to java, or with MY_PROTOCOL=https as an environment variable, you'd get https in the host.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With