https://kotlinlang.org logo
#ktor
Title
# ktor
s

Sourabh Rawat

02/14/2020, 7:46 AM
how to injection ktor
Application
when using koin.
t

Tim Malseed

02/14/2020, 8:07 AM
What have you tried?
s

Sourabh Rawat

02/14/2020, 8:54 AM
currently I solved it by this, but is there a better approach.
Copy code
fun Application.installFeatures() {
  val application = this
  install(DefaultHeaders)
  install(CallLogging)
  install(MicrometerMetrics) {
    registry = LoggingMeterRegistry() //Log for now. only for testing phase.
  }
  install(ContentNegotiation) {
    serialization(
      json = Json(
        DefaultJsonConfiguration.copy(
          strictMode = false,
          prettyPrint = true
        )
      )
    )
  }
  install(Koin) {
    val ktorModule = module {
      single { application }
    }
    slf4jLogger()
    modules(listOf(ktorModule, appModule))
  }
}
31 Views