• Home
  • Raw
  • Download

Lines Matching full:router

1 Nest a [`Router`] at some path.
11 Router,
14 let user_routes = Router::new().route("/:id", get(|| async {}));
16 let team_routes = Router::new().route("/", post(|| async {}));
18 let api_routes = Router::new()
22 let app = Router::new().nest("/api", api_routes);
48 Router,
59 let users_api = Router::new().route("/users/:id", get(users_get));
61 let app = Router::new().nest("/:version/api", users_api);
74 use axum::{routing::get, http::Uri, Router};
76 let nested_router = Router::new()
81 let app = Router::new()
93 If a nested router doesn't have its own fallback then it will inherit the
94 fallback from the outer router:
97 use axum::{routing::get, http::StatusCode, handler::Handler, Router};
103 let api_routes = Router::new().route("/users", get(|| async {}));
105 let app = Router::new()
108 # let _: Router = app;
113 the fallback from the outer router, i.e. the `fallback` function.
115 If the nested router has its own fallback then the outer fallback will not be
124 Router,
138 let api_routes = Router::new()
142 let app = Router::new()
145 # let _: Router = app;
152 When combining [`Router`]s with this method, each [`Router`] must have the
154 [`Router::with_state`] to provide the state and make the types match:
158 Router,
171 let inner_router = Router::new()
177 let app = Router::new()
181 # let _: axum::Router = app;
184 Note that the inner router will still inherit the fallback from the outer
185 router.
189 - If the route overlaps with another route. See [`Router::route`]
195 [fallbacks]: Router::fallback