I am using actix_web 4.0 as the web framework, now I recieve an callback from third party service. How to get the body from the callback post request? I have tried like this:
use actix_web::{get, post, web, App, HttpRequest, HttpResponse, HttpServer, Responder};
#[post("/echo")]
async fn echo(req: HttpRequest) -> impl Responder {
let qs = req.clone();
let s = qs.query_string();
// this code to get body did not work
let body = req.body();
let query_str = s.clone();
HttpResponse::Ok().body("ok")
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.service(echo)
})
.bind(("127.0.0.1", 8080))?
.run()
.await
}
seems could not get the body string directly. And I did not know the callback body content and did not know how to define a entity to recieve. How to get the body string from the http callback invoke? this is the cargo.toml:
[dependencies]
actix-web = "4"