mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-10 18:38:22 +00:00
Return null instead of skipping field on empty success response
This commit is contained in:
parent
c7e9e9dfee
commit
e93c1cc438
1 changed files with 3 additions and 2 deletions
|
@ -45,8 +45,9 @@ struct RpcRequest {
|
||||||
struct RpcResponse {
|
struct RpcResponse {
|
||||||
id: i64,
|
id: i64,
|
||||||
jsonrpc: String,
|
jsonrpc: String,
|
||||||
|
// Note: this Option<Option<>> is for distinguishing between success without a result (null) and and error where the field is skipped
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
result: Option<Box<RawValue>>,
|
result: Option<Option<Box<RawValue>>>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
error: Option<RpcErrorObject>,
|
error: Option<RpcErrorObject>,
|
||||||
}
|
}
|
||||||
|
@ -116,7 +117,7 @@ async fn api_handler(
|
||||||
Ok(res) => Json(RpcResponse {
|
Ok(res) => Json(RpcResponse {
|
||||||
id: req.id,
|
id: req.id,
|
||||||
jsonrpc: req.jsonrpc,
|
jsonrpc: req.jsonrpc,
|
||||||
result: res,
|
result: Some(res),
|
||||||
error: None,
|
error: None,
|
||||||
}),
|
}),
|
||||||
Err(err) => Json(RpcResponse {
|
Err(err) => Json(RpcResponse {
|
||||||
|
|
Loading…
Add table
Reference in a new issue