use http::Request; use http_body_util::BodyExt; use hyper::body::Incoming; use serde::de::DeserializeOwned; use std::error::Error; pub struct Requester; impl Requester { pub async fn extract_body(req: Request) -> Result> where T: DeserializeOwned, { let body = req.collect().await?.to_bytes(); Ok(serde_json::from_slice(&body)?) } pub async fn extract_body_str( req: Request, ) -> Result> { let body = req.collect().await?.to_bytes(); Ok(String::from_utf8(body.to_vec())?) } }