transaction.BakuTransactionFeature.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of baku Show documentation
Show all versions of baku Show documentation
helps you focus your REST API back-end on the business logic
package com.github.fluidsonic.baku
import io.ktor.application.ApplicationCallPipeline
import io.ktor.application.ApplicationFeature
import io.ktor.application.call
import io.ktor.util.AttributeKey
internal class BakuTransactionFeature(
private val service: BakuService,
private val context: Context
) : ApplicationFeature {
override val key = AttributeKey("Baku: transaction feature")
@Suppress("UNCHECKED_CAST")
override fun install(pipeline: ApplicationCallPipeline, configure: Unit.() -> Unit) {
Unit.configure()
pipeline.intercept(ApplicationCallPipeline.Setup) {
call.attributes.put(transactionAttributeKey, service.createTransaction(context = [email protected], call = call))
}
}
companion object {
val transactionAttributeKey = AttributeKey("Baku: transaction")
}
}