I use crate scylla that use tokio 1, so i must use crate actix-web 4.0 beta. Now i have problem that use actix_web::client::Client show error :
3 | use actix_web::client::Client;
| ^^^^^^ could not find `client` in `actix_web`
i want to hit API inside actix handler with this code :
pub(crate) async fn proses_mapmatching(data: web::Data<AppState>) -> impl Responder {
let client = Client::default();
let res = client.post("http://localhost:8002/trace_route")
.send()
.await
.unwrap()
.body()
.await;
println!("Response: {:?}", res);
HttpResponse::Ok().body(format!("Hello {:?}", res))
}
Any idea to still use actix-web 4 with reqest post insede handler function ? Thanks
ANSWER CODE with AWC - Thanks to Mr. @kmdreko
pub(crate) async fn proses_mapmatching(data: web::Data<AppState>) -> impl Responder {
let mut client = awc::Client::default();
let response = client.post("http://localhost:8002/trace_route")
.send_body("Raw body contents")
.await;
println!("Response: {:?}", response.unwrap().body().await);
HttpResponse::Ok().body(format!("Hello {}!", rows.len()))
}