I want to write a server using the current master branch of Hyper that saves a message that is delivered by a POST request and sends this message to every incoming GET reque
Most of the answers on this topic are outdated or overly complicated. The solution is pretty simple:
/*
WARNING for beginners!!! This use statement
is important so we can later use .data() method!!!
*/
use hyper::body::HttpBody;
let my_vector: Vec = request.into_body().data().await.unwrap().unwrap().to_vec();
let my_string = String::from_utf8(my_vector).unwrap();
You can also use body::to_bytes as @euclio answered. Both approaches are straight-forward! Don't forget to handle unwrap properly.