Skip to content

Commit 9e8999f

Browse files
author
Fuyang Liu
committed
Fix up typo and update some naming
1 parent f6bc0cc commit 9e8999f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

examples/echo.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ async fn echo(req: Request<Body>) -> Result<Response<Body>, hyper::Error> {
2424

2525
// Convert to uppercase before sending back to client using a stream.
2626
(&Method::POST, "/echo/uppercase") => {
27-
let mapping = req.into_body().map_ok(|chunk| {
27+
let chunk_stream = req.into_body().map_ok(|chunk| {
2828
chunk
2929
.iter()
3030
.map(|byte| byte.to_ascii_uppercase())
3131
.collect::<Vec<u8>>()
3232
});
33-
Ok(Response::new(Body::wrap_stream(mapping)))
33+
Ok(Response::new(Body::wrap_stream(chunk_stream)))
3434
}
3535

3636
// 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> {
4040
// So here we do `.await` on the future, waiting on concatenating the full body,
4141
// then afterwards the content can be reversed. Only then can we return a `Response`.
4242
(&Method::POST, "/echo/reversed") => {
43-
let chunks = req.into_body().try_concat().await;
43+
let whole_chunk = req.into_body().try_concat().await;
4444

45-
let reversed_body = chunks.map(move |chunk| {
45+
let reversed_chunk = whole_chunk.map(move |chunk| {
4646
chunk.iter().rev().cloned().collect::<Vec<u8>>()
4747

4848
})?;
49-
Ok(Response::new(Body::from(reversed_body)))
49+
Ok(Response::new(Body::from(reversed_chunk)));
5050
}
5151

52-
// Return The 404 Not Found for other routes.
52+
// Return the 404 Not Found for other routes.
5353
_ => {
5454
let mut not_found = Response::new(Body::empty());
5555
*not_found.status_mut() = StatusCode::NOT_FOUND;

0 commit comments

Comments
 (0)