Skip to content

Commit 06bf5f7

Browse files
authored
Merge pull request #429 from PeteJodo/examples-nested
Add an example for nesting a tide server
2 parents 588d2f1 + 135f952 commit 06bf5f7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

examples/nested.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use async_std::task;
2+
3+
fn main() -> Result<(), std::io::Error> {
4+
task::block_on(async {
5+
let mut app = tide::new();
6+
app.at("/").get(|_| async move { "Root" });
7+
app.at("/api").nest({
8+
let mut api = tide::new();
9+
api.at("/hello").get(|_| async move { "Hello, world" });
10+
api.at("/goodbye").get(|_| async move { "Goodbye, world" });
11+
api
12+
});
13+
app.listen("127.0.0.1:8080").await?;
14+
Ok(())
15+
})
16+
}

0 commit comments

Comments
 (0)