postJson

abstract fun postJson(scope: CoroutineScope, url: String, json: String?, requestBuilder: HttpClientRequest.() -> Unit?): Deferred<HttpClientResponse>

异步发起一个 HTTP POST 请求,发送 JSON 格式的数据。 Content-Type 头将自动设置为 application/json

Return

一个 Deferred 对象,其未来结果是服务器的响应 HttpClientResponse

Parameters

scope

执行此异步操作的协程作用域。

url

请求的目标 URL。

json

一个可选的、代表请求体的 JSON 格式字符串。

requestBuilder

一个可选的请求构建器 lambda,用于进行高级配置。