add fromHex extension
This commit is contained in:
parent
dd9a5da3ae
commit
ee3867e946
@ -1,6 +1,6 @@
|
||||
package com.insanusmokrassar.postssystem.ktor
|
||||
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.encodeToHexString
|
||||
import kotlinx.serialization.*
|
||||
|
||||
fun <T> T.toHex(with: SerializationStrategy<T>) = standardKtorSerialFormat.encodeToHexString(with, this)
|
||||
fun <T> String.fromHex(with: DeserializationStrategy<T>): T = standardKtorSerialFormat.decodeFromHexString(with, this)
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.insanusmokrassar.postssystem.ktor.server
|
||||
|
||||
import com.insanusmokrassar.postssystem.ktor.fromHex
|
||||
import com.insanusmokrassar.postssystem.ktor.standardKtorSerialFormat
|
||||
import io.ktor.application.ApplicationCall
|
||||
import io.ktor.http.HttpStatusCode
|
||||
@ -28,12 +29,7 @@ suspend fun <T> ApplicationCall.uniload(
|
||||
fun <T> ApplicationCall.uniloadFromQuery(
|
||||
parameterName: String,
|
||||
deserializer: DeserializationStrategy<T>
|
||||
): T? {
|
||||
return standardKtorSerialFormat.decodeFromHexString(
|
||||
deserializer,
|
||||
getQueryParameter(parameterName) ?: return null
|
||||
)
|
||||
}
|
||||
): T? = getQueryParameter(parameterName) ?.fromHex(deserializer)
|
||||
|
||||
suspend fun <T> ApplicationCall.uniloadFromQueryOrSendError(
|
||||
parameterName: String,
|
||||
|
Loading…
Reference in New Issue
Block a user