All Downloads are FREE. Search and download functionalities are using the official Maven repository.

transaction.BakuTransactionFeature.kt Maven / Gradle / Ivy

There is a newer version: 0.9.27
Show newest version
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")
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy