Hi guys, I’m creating my first server that latter ...
# ktor
g
Hi guys, I’m creating my first server that latter will be used in a KMP project. Question: how can I read values from, let’s say, a
local.properties
? This was my idea:
Copy code
private fun getSecret(envKey: String, localKey: String): String = System.getenv(envKey) ?: ...(localKey,"")
Thanks!
b
Expect/actual into platform file apis
E.g. fs on node or File on Java
👍 1
g
sometimes my brain freezes a bit eheh 😅
Copy code
private fun getSecret(envKey: String, localKey: String): String {
    val path = "./local.properties"
    return if (File(path).exists()) {
        Properties().apply { load(FileInputStream(path)) }.getProperty(localKey, "")
    } else System.getenv(envKey) ?: ""
}