@@ -24,13 +24,13 @@ async fn echo(req: Request<Body>) -> Result<Response<Body>, hyper::Error> {
24
24
25
25
// Convert to uppercase before sending back to client using a stream.
26
26
( & Method :: POST , "/echo/uppercase" ) => {
27
- let mapping = req. into_body ( ) . map_ok ( |chunk| {
27
+ let chunk_stream = req. into_body ( ) . map_ok ( |chunk| {
28
28
chunk
29
29
. iter ( )
30
30
. map ( |byte| byte. to_ascii_uppercase ( ) )
31
31
. collect :: < Vec < u8 > > ( )
32
32
} ) ;
33
- Ok ( Response :: new ( Body :: wrap_stream ( mapping ) ) )
33
+ Ok ( Response :: new ( Body :: wrap_stream ( chunk_stream ) ) )
34
34
}
35
35
36
36
// Reverse the entire body before sending back to the client.
@@ -40,16 +40,16 @@ async fn echo(req: Request<Body>) -> Result<Response<Body>, hyper::Error> {
40
40
// So here we do `.await` on the future, waiting on concatenating the full body,
41
41
// then afterwards the content can be reversed. Only then can we return a `Response`.
42
42
( & Method :: POST , "/echo/reversed" ) => {
43
- let chunks = req. into_body ( ) . try_concat ( ) . await ;
43
+ let whole_chunk = req. into_body ( ) . try_concat ( ) . await ;
44
44
45
- let reversed_body = chunks . map ( move |chunk| {
45
+ let reversed_chunk = whole_chunk . map ( move |chunk| {
46
46
chunk. iter ( ) . rev ( ) . cloned ( ) . collect :: < Vec < u8 > > ( )
47
47
48
48
} ) ?;
49
- Ok ( Response :: new ( Body :: from ( reversed_body ) ) )
49
+ Ok ( Response :: new ( Body :: from ( reversed_chunk ) ) ) ;
50
50
}
51
51
52
- // Return The 404 Not Found for other routes.
52
+ // Return the 404 Not Found for other routes.
53
53
_ => {
54
54
let mut not_found = Response :: new ( Body :: empty ( ) ) ;
55
55
* not_found. status_mut ( ) = StatusCode :: NOT_FOUND ;
0 commit comments