Skip to content

Commit f5b428e

Browse files
committed
update root README
1 parent 190b3c5 commit f5b428e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,18 @@ async-std = { version = "1.5", features = ["attributes"] }
5757
```
5858

5959
```rust
60-
use roa::App;
60+
use roa::{App, Context};
6161
use roa::preload::*;
6262
use std::error::Error as StdError;
63+
async fn hello(ctx: &mut Context<()>) -> roa::Result {
64+
ctx.resp.write_text("Hello, World");
65+
Ok(())
66+
}
67+
6368

6469
#[async_std::main]
6570
async fn main() -> Result<(), Box<dyn StdError>> {
66-
let mut app = App::new(());
67-
app.end(|mut ctx| async move {
68-
ctx.resp_mut().write("Hello, World");
69-
Ok(())
70-
});
71+
let app = App::new(()).end(hello);
7172
app.listen("127.0.0.1:8000", |addr| {
7273
println!("Server is listening on {}", addr)
7374
})?

0 commit comments

Comments
 (0)