Skip to content

Instantly share code, notes, and snippets.

@yasuabe
Created April 14, 2019 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yasuabe/6481307d649af92972cfa53cfc8a424a to your computer and use it in GitHub Desktop.
Save yasuabe/6481307d649af92972cfa53cfc8a424a to your computer and use it in GitHub Desktop.
multi env hello world using Ciris
package exercise.ciris.qiita1
import ciris.api.Id
import ciris.{ConfigResult, env, withValues, loadConfig}
import ciris.generic._
object MainMulti {
case class Config(name: String)
val config: ConfigResult[Id, Config] =
withValues(env[Option[String]]("APP_ENV")) {
case Some("PRODUCTION") => loadConfig(env[String]("NAME"))(Config)
case _ => loadConfig { Config("local") }
}
def main(args: Array[String]): Unit = {
val greeting = config.result.fold(_.message, c => s"Hello, ${c.name}!")
println(greeting)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment