Replies: 1 comment
-
The single threaded example is meant to show a very specific thing: that you can use hyper with a local executor. It's somewhat of an advanced topic, where the other examples are meant to be show the other features more, like the echo or web_api examples. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey,
as a hyper and Rust noobie, based on examples/single_threaded.rs, I spent a good while trying to modify the example to actually read the incoming request body, but got confused by the following issue:
As it turns out, that's because my service_fn used a function that had the following signature:
async fn handle_request(req: hyper::Request<Body>) -> http::Result<http::Response<String>>
,where
Body
refers to the struct defined in the example. Instead, one had to usereq: hyper::Request<hyper::body::Incoming>
in order to satisfy that bound. As a new user, figuring out that I was supposed to use a differentBody
type than what we just defined was quite confusing.For anyone wondering how the body is supposed to be read, it can be found in examples/web_api.rs:
let whole_body = req.collect().await?.aggregate();
Have a good day!
Beta Was this translation helpful? Give feedback.
All reactions