Closed jk-gan closed 4 years ago
Previously when we want to use nested route, we have to write:
// declare a nested router let mut form_router = Router::new(); // declare nested route form_router.get("/formtest", |ctx: Context| async move { ctx.build_file("./test.html").await.ok() }); // register the nested router to the app app.use_router("/forms/", form_router);
With the syntactic sugar:
app.scope("form", |router: &mut Router| { router.get("/formtest", |ctx: Context| async move { ctx.build_file("/.test.html").await.ok() }); });
Previously when we want to use nested route, we have to write:
With the syntactic sugar: