Reputation: 9724
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.
Upvotes: 9
Views: 3578
Reputation: 989
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.
Upvotes: 6