Skip to content

Instantly share code, notes, and snippets.

@anderssv
Created April 10, 2018 08:03
Show Gist options
  • Save anderssv/528c7fdb3538c44ca6efec6874010d68 to your computer and use it in GitHub Desktop.
Save anderssv/528c7fdb3538c44ca6efec6874010d68 to your computer and use it in GitHub Desktop.
Dependency Injection Blog - Load Config
fun loadConfig(randomPort: Boolean = false): DependencyInjectionApplicationConfig {
val properties = loadRuntimeProperties()
return DependencyInjectionApplicationConfig(
if (randomPort) 0 else requiredEnv(properties, "PORT", "5000").toInt(),
requiredEnv(properties, "DATABASE_URL"),
env(properties, "DATABASE_USER")
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment