mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-21 08:19:24 +00:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
13ca419473 | |||
b80f1a0773 | |||
e85101c74e | |||
90668bdf63 | |||
e1a00079a5 | |||
e3add4df42 | |||
ced1a3bccb | |||
8d13a14343 |
11
CHANGELOG.md
11
CHANGELOG.md
@@ -1,5 +1,16 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.5.2
|
||||||
|
|
||||||
|
* `Ktor`:
|
||||||
|
* `Client`:
|
||||||
|
* Fixes in `UnifiedRequester`
|
||||||
|
|
||||||
|
## 0.5.1
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `Kotlin Serialization`: `1.2.0` -> `1.2.1`
|
||||||
|
|
||||||
## 0.5.0
|
## 0.5.0
|
||||||
|
|
||||||
**Notice**: This version is still depend on Kotlin
|
**Notice**: This version is still depend on Kotlin
|
||||||
|
@@ -9,7 +9,7 @@ org.gradle.jvmargs=-Xmx2g
|
|||||||
|
|
||||||
kotlin_version=1.5.0
|
kotlin_version=1.5.0
|
||||||
kotlin_coroutines_version=1.5.0
|
kotlin_coroutines_version=1.5.0
|
||||||
kotlin_serialisation_core_version=1.2.0
|
kotlin_serialisation_core_version=1.2.1
|
||||||
kotlin_exposed_version=0.31.1
|
kotlin_exposed_version=0.31.1
|
||||||
|
|
||||||
ktor_version=1.5.4
|
ktor_version=1.5.4
|
||||||
@@ -45,5 +45,5 @@ dokka_version=1.4.32
|
|||||||
# Project data
|
# Project data
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=0.5.0
|
version=0.5.2
|
||||||
android_code_version=41
|
android_code_version=43
|
||||||
|
@@ -15,30 +15,21 @@ class UnifiedRequester(
|
|||||||
suspend fun <ResultType> uniget(
|
suspend fun <ResultType> uniget(
|
||||||
url: String,
|
url: String,
|
||||||
resultDeserializer: DeserializationStrategy<ResultType>
|
resultDeserializer: DeserializationStrategy<ResultType>
|
||||||
): ResultType = client.get<StandardKtorSerialInputData>(
|
): ResultType = client.uniget(url, resultDeserializer, serialFormat)
|
||||||
url
|
|
||||||
).let {
|
|
||||||
serialFormat.decodeDefault(resultDeserializer, it)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun <T> encodeUrlQueryValue(
|
fun <T> encodeUrlQueryValue(
|
||||||
serializationStrategy: SerializationStrategy<T>,
|
serializationStrategy: SerializationStrategy<T>,
|
||||||
value: T
|
value: T
|
||||||
) = serialFormat.encodeHex(
|
) = serializationStrategy.encodeUrlQueryValue(
|
||||||
serializationStrategy,
|
value,
|
||||||
value
|
serialFormat
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun <BodyType, ResultType> unipost(
|
suspend fun <BodyType, ResultType> unipost(
|
||||||
url: String,
|
url: String,
|
||||||
bodyInfo: BodyPair<BodyType>,
|
bodyInfo: BodyPair<BodyType>,
|
||||||
resultDeserializer: DeserializationStrategy<ResultType>
|
resultDeserializer: DeserializationStrategy<ResultType>
|
||||||
) = client.post<StandardKtorSerialInputData>(url) {
|
) = client.unipost(url, bodyInfo, resultDeserializer, serialFormat)
|
||||||
body = serialFormat.encodeDefault(bodyInfo.first, bodyInfo.second)
|
|
||||||
}.let {
|
|
||||||
serialFormat.decodeDefault(resultDeserializer, it)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <T> createStandardWebsocketFlow(
|
fun <T> createStandardWebsocketFlow(
|
||||||
url: String,
|
url: String,
|
||||||
@@ -51,14 +42,30 @@ val defaultRequester = UnifiedRequester()
|
|||||||
|
|
||||||
suspend fun <ResultType> HttpClient.uniget(
|
suspend fun <ResultType> HttpClient.uniget(
|
||||||
url: String,
|
url: String,
|
||||||
resultDeserializer: DeserializationStrategy<ResultType>
|
resultDeserializer: DeserializationStrategy<ResultType>,
|
||||||
) = defaultRequester.uniget(url, resultDeserializer)
|
serialFormat: StandardKtorSerialFormat = standardKtorSerialFormat
|
||||||
|
) = get<StandardKtorSerialInputData>(
|
||||||
|
url
|
||||||
|
).let {
|
||||||
|
serialFormat.decodeDefault(resultDeserializer, it)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fun <T> SerializationStrategy<T>.encodeUrlQueryValue(value: T) = defaultRequester.encodeUrlQueryValue(this, value)
|
fun <T> SerializationStrategy<T>.encodeUrlQueryValue(
|
||||||
|
value: T,
|
||||||
|
serialFormat: StandardKtorSerialFormat = standardKtorSerialFormat
|
||||||
|
) = serialFormat.encodeHex(
|
||||||
|
this,
|
||||||
|
value
|
||||||
|
)
|
||||||
|
|
||||||
suspend fun <BodyType, ResultType> HttpClient.unipost(
|
suspend fun <BodyType, ResultType> HttpClient.unipost(
|
||||||
url: String,
|
url: String,
|
||||||
bodyInfo: BodyPair<BodyType>,
|
bodyInfo: BodyPair<BodyType>,
|
||||||
resultDeserializer: DeserializationStrategy<ResultType>
|
resultDeserializer: DeserializationStrategy<ResultType>,
|
||||||
) = defaultRequester.unipost(url, bodyInfo, resultDeserializer)
|
serialFormat: StandardKtorSerialFormat = standardKtorSerialFormat
|
||||||
|
) = post<StandardKtorSerialInputData>(url) {
|
||||||
|
body = serialFormat.encodeDefault(bodyInfo.first, bodyInfo.second)
|
||||||
|
}.let {
|
||||||
|
serialFormat.decodeDefault(resultDeserializer, it)
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user