starting with xs support
parent
17931ea1ca
commit
3036ba243c
|
|
@ -0,0 +1,10 @@
|
|||
package de.itkl.httpClient
|
||||
|
||||
import kotlinx.datetime.Instant
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class BearerToken(
|
||||
val tokenString: String,
|
||||
val validUntil: Instant
|
||||
)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
package de.itkl.httpClient
|
||||
|
||||
class BearerTokenCache {
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package de.itkl.httpClient
|
||||
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import io.ktor.client.plugins.api.*
|
||||
import io.ktor.util.*
|
||||
import org.koin.core.component.KoinComponent
|
||||
|
||||
private val Log = KotlinLogging.logger { }
|
||||
val smartCloudAuthPlugin = createClientPlugin("SmartCloudAuth") {
|
||||
on(Send) { request ->
|
||||
request.attributes.getOrNull(AttributeKey<String>("user"))?.let { username ->
|
||||
Log.info { "Provide bearer token for $username" }
|
||||
TODO("retrieve user token ")
|
||||
}
|
||||
TODO()
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package de.itkl.httpClient.clients
|
||||
|
||||
import io.ktor.client.*
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
|
||||
abstract class RestClient : KoinComponent {
|
||||
private val httpClient by inject<HttpClient>()
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package de.itkl.httpClient.clients
|
||||
|
||||
import io.ktor.client.*
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
|
||||
class XsClient : KoinComponent {
|
||||
private val httpClient by inject<HttpClient>()
|
||||
}
|
||||
|
|
@ -10,5 +10,6 @@ fun createHttpClient(): HttpClient {
|
|||
install(ContentNegotiation) {
|
||||
json()
|
||||
}
|
||||
install(smartCloudAuthPlugin)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue