Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set default value and also use Environment variable in application.conf


I want to set value for one of config variable in application.conf using environment variable. But if this env variable is not present I want to default config to a certain value instead of erring out.
Is this possible? Here is setting for reference.

test.myframework {
host = ${TEST_HOST_NAME}
}

Here if TEST_HOST_NAME if not present can I default host to localhost?

like image 486
Sandy Avatar asked May 22 '17 05:05

Sandy


People also ask

What format does the env var and its values are stored?

In Microsoft Windows, each environment variable's default value is stored in the Windows Registry or set in the AUTOEXEC. BAT file.

Are env vars always strings?

Also, env variables are always strings.


1 Answers

This is described in the play documentation Production Configuration:

my.key = defaultvalue
my.key = ${?MY_KEY_ENV}
like image 68
rethab Avatar answered Oct 07 '22 07:10

rethab