If I want to read values from my `application.conf...
# ktor
l
If I want to read values from my
application.conf
, do I need to separately add the typesafe config as a dependency or do I somehow have access to this functionality as an indirect dependency?
e
l
Thanks so much. I was not able to find that for some reason!
👍 1
so I will need access to the Application somehow wherever I want to access environment? I'm writing a standalone class (a client for some API) and that's where I'm needing to read the conf. I suppose I should just make the class or its functions take those values as args and then access those within the routes
Probably good design practice anyways 😛
If I'm in the context of a
fun Route.createUserRoute()
, is there a way to get a handle on the Application? Without that, I'll get a
'val environment: ApplicationEnvironment?' can't be called in this context by implicit receiver. Use the explicit one if necessary
error.
Should I just pass it down from a level higher, i.e. in
Copy code
fun Application.userRoutes() {
    routing {
        createUserRoute()
    }
}
e
Could you try specifying the explicit receiver like
this@userRoutes.environment
?
l
Thanks.
this@createUserRoute.environment
in my case.
I also didn't realize
Route
does have
environment
but it's nullable:
Copy code
open class Route(    val parent: Route?,     val selector: RouteSelector,     val developmentMode: Boolean = false,     val environment: ApplicationEnvironment? = null) : ApplicationCallPipeline
ugh, bad formatting
189 Views