use reqwest json() method (#525)

This commit is contained in:
Giacomo Pasini 2023-11-11 16:49:18 +01:00 committed by GitHub
parent 421ea6c0c7
commit a524cc2dcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 8 deletions

View File

@ -10,8 +10,7 @@ pub async fn get_blobs(
const BLOBS_PATH: &str = "da/blobs"; const BLOBS_PATH: &str = "da/blobs";
CLIENT CLIENT
.post(node.join(BLOBS_PATH).unwrap()) .post(node.join(BLOBS_PATH).unwrap())
.header("Content-Type", "application/json") .json(&ids)
.body(serde_json::to_string(&ids).unwrap())
.send() .send()
.await? .await?
.json() .json()

View File

@ -9,8 +9,7 @@ where
const NODE_CERT_PATH: &str = "mempool/add/cert"; const NODE_CERT_PATH: &str = "mempool/add/cert";
CLIENT CLIENT
.post(node.join(NODE_CERT_PATH).unwrap()) .post(node.join(NODE_CERT_PATH).unwrap())
.header("Content-Type", "application/json") .json(cert)
.body(serde_json::to_string(cert).unwrap())
.send() .send()
.await .await
} }

View File

@ -10,12 +10,11 @@ pub async fn get_block_contents(
block: &BlockId, block: &BlockId,
) -> Result<Option<Block<Tx, Certificate>>, reqwest::Error> { ) -> Result<Option<Block<Tx, Certificate>>, reqwest::Error> {
const BLOCK_PATH: &str = "storage/block"; const BLOCK_PATH: &str = "storage/block";
let block = CLIENT CLIENT
.post(node.join(BLOCK_PATH).unwrap()) .post(node.join(BLOCK_PATH).unwrap())
.body(serde_json::to_string(block).unwrap()) .json(block)
.send() .send()
.await? .await?
.json() .json()
.await?; .await
Ok(block)
} }