mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
KtorRequestsExecutor custom json formatter
This commit is contained in:
parent
b0f7563191
commit
6f04baea4e
@ -29,6 +29,8 @@ must be regular text
|
|||||||
|
|
||||||
### 0.9.3
|
### 0.9.3
|
||||||
|
|
||||||
|
* `KtorRequestsExecutor` now can use custom `JSON` string formatter (by default - non strict)
|
||||||
|
|
||||||
### 0.8.5
|
### 0.8.5
|
||||||
|
|
||||||
* Add extension `String#toMarkdown`
|
* Add extension `String#toMarkdown`
|
||||||
|
@ -22,7 +22,8 @@ class KtorRequestsExecutor(
|
|||||||
hostUrl: String = "https://api.telegram.org",
|
hostUrl: String = "https://api.telegram.org",
|
||||||
callsFactories: List<KtorCallFactory> = emptyList(),
|
callsFactories: List<KtorCallFactory> = emptyList(),
|
||||||
excludeDefaultFactories: Boolean = false,
|
excludeDefaultFactories: Boolean = false,
|
||||||
private val requestsLimiter: RequestLimiter = EmptyLimiter
|
private val requestsLimiter: RequestLimiter = EmptyLimiter,
|
||||||
|
private val jsonFormatter: JSON = JSON.nonstrict
|
||||||
) : BaseRequestsExecutor(token, hostUrl) {
|
) : BaseRequestsExecutor(token, hostUrl) {
|
||||||
constructor(
|
constructor(
|
||||||
token: String,
|
token: String,
|
||||||
@ -59,7 +60,7 @@ class KtorRequestsExecutor(
|
|||||||
throw IllegalArgumentException("Can't execute request: $request")
|
throw IllegalArgumentException("Can't execute request: $request")
|
||||||
}
|
}
|
||||||
val content = call.response.content.toByteArray().toString(Charset.defaultCharset())
|
val content = call.response.content.toByteArray().toString(Charset.defaultCharset())
|
||||||
val responseObject = JSON.parse(
|
val responseObject = jsonFormatter.parse(
|
||||||
ResponseParameters.serializer(request.resultSerializer()),
|
ResponseParameters.serializer(request.resultSerializer()),
|
||||||
content
|
content
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user