Created
October 4, 2016 10:57
-
-
Save dos65/e2ab9441b75c54b69b3c1486edb92043 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File | |
import com.typesafe.config.{ ConfigFactory, ConfigRenderOptions } | |
/** | |
* discovery { | |
* host = "discovery.global.livetex" | |
* port = 80 | |
* circuit = "msgtest" | |
* } | |
**/ | |
case class DiscoveryConfig( | |
host: String, | |
port: Int, | |
circuit: String | |
) | |
case class ApplicationConfig( | |
discovery: DiscoveryConfig | |
) | |
object ApplicationConfig { | |
def apply(path: String): ApplicationConfig = { | |
import org.json4s._ | |
import org.json4s.native.JsonMethods._ | |
implicit val formats = DefaultFormats | |
val config = ConfigFactory.parseFile(new File(path)) | |
val json = config.root().render(ConfigRenderOptions.concise()) | |
parse(json).camelizeKeys.extract[ApplicationConfig] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment