Skip to content

Commit c04d92f

Browse files
author
Fuyang Liu
committed
Try fix up - not working
1 parent a392686 commit c04d92f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

examples/echo.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ extern crate hyper;
66
use hyper::{Body, Method, Request, Response, Server, StatusCode};
77
use hyper::service::{make_service_fn, service_fn};
88
use futures_util::TryStreamExt;
9+
use futures_util::try_future::TryFutureExt;
910

1011
/// This is our service handler. It receives a Request, routes on its
1112
/// path, and returns a Future of a Response.
@@ -42,11 +43,13 @@ async fn echo(req: Request<Body>) -> Result<Response<Body>, hyper::Error> {
4243
// future, waiting on concatenating the full body, so that
4344
// it can be reversed. Only then can we return a `Response`.
4445
(&Method::POST, "/echo/reversed") => {
45-
let reversed = req.into_body().concat2().map(move |chunk| {
46+
let chunks = req.into_body().try_concat().await;
47+
48+
let reversed = chunks.map(move |chunk| {
4649
let body = chunk.iter().rev().cloned().collect::<Vec<u8>>();
4750
*response.body_mut() = Body::from(body);
4851
response
49-
});
52+
})?;
5053

5154
return Ok(reversed);
5255
}

0 commit comments

Comments
 (0)