mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Shamrock
: fix #66
This commit is contained in:
parent
4266afd1a5
commit
2c49b10772
@ -170,12 +170,12 @@ suspend fun PipelineContext<Unit, ApplicationCall>.fetchPostOrThrow(key: String)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun PipelineContext<Unit, ApplicationCall>.isJsonData(): Boolean {
|
fun PipelineContext<Unit, ApplicationCall>.isJsonData(): Boolean {
|
||||||
return ContentType.Application.Json == call.request.contentType() || call.attributes[isJsonKey]
|
return ContentType.Application.Json == call.request.contentType() || (isJsonKey in call.attributes && call.attributes[isJsonKey])
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun PipelineContext<Unit, ApplicationCall>.isJsonString(key: String): Boolean {
|
suspend fun PipelineContext<Unit, ApplicationCall>.isJsonString(key: String): Boolean {
|
||||||
if (!isJsonData()) return true
|
if (!isJsonData()) return true
|
||||||
val data = if (call.attributes.contains(jsonKey)) {
|
val data = if (jsonKey in call.attributes) {
|
||||||
call.attributes[jsonKey]
|
call.attributes[jsonKey]
|
||||||
} else {
|
} else {
|
||||||
Json.parseToJsonElement(call.receiveText()).jsonObject.also {
|
Json.parseToJsonElement(call.receiveText()).jsonObject.also {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user