Skip to content

Commit fda7ba9

Browse files
committed
update example
Signed-off-by: Yoshua Wuyts <[email protected]>
1 parent 1cb8294 commit fda7ba9

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

examples/server.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use async_h1::{server, Body};
22
use async_std::prelude::*;
3-
use async_std::{io, net, task};
3+
use async_std::net;
4+
use async_std::task;
45

56
fn main() -> Result<(), async_h1::Exception> {
67
task::block_on(async {
@@ -9,26 +10,12 @@ fn main() -> Result<(), async_h1::Exception> {
910
let mut incoming = listener.incoming();
1011

1112
while let Some(stream) = incoming.next().await {
12-
// task::spawn(async move {
13-
// let stream = stream?;
14-
// let (reader, writer) = &mut (&stream, &stream);
15-
// let req = server::decode(reader).await?;
16-
// if let server::OptionalRequest::Request(req) = req {
17-
// // dbg!(req);
18-
// let body = Body::from_string("hello chashu".to_owned());
19-
// let mut res = server::encode(http::Response::new(body)).await?;
20-
// io::copy(&mut res, writer).await?;
21-
// }
22-
// Ok::<(), async_h1::Exception>(())
23-
// });
2413
task::spawn(async {
2514
let stream = stream?;
2615
let (reader, writer) = &mut (&stream, &stream);
27-
server::connect(reader, writer, |req| {
28-
async {
29-
let body = Body::from_string("hello chashu".to_owned());
30-
Ok(http::Response::new(body))
31-
}
16+
server::connect(reader, writer, |_| async {
17+
let body = Body::from_string("hello chashu".to_owned());
18+
Ok(http::Response::new(body))
3219
})
3320
.await
3421
});

0 commit comments

Comments
 (0)