Adde route method to builder for single route.
Removed state () from Router
This commit is contained in:
parent
cdc8f5e463
commit
173bbc2ca5
@ -42,6 +42,11 @@ impl AppBuilder {
|
|||||||
Self::default()
|
Self::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn route(mut self, route: Router) -> Self {
|
||||||
|
self.router = self.router.merge(route);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn routes(mut self, routes: impl IntoIterator<Item = Router>) -> Self {
|
pub fn routes(mut self, routes: impl IntoIterator<Item = Router>) -> Self {
|
||||||
self.router = routes.into_iter().fold(self.router, Router::merge);
|
self.router = routes.into_iter().fold(self.router, Router::merge);
|
||||||
self
|
self
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#[cfg(feature = "axum")]
|
#[cfg(feature = "axum")]
|
||||||
macro_rules! router {
|
macro_rules! router {
|
||||||
($body:expr) => {
|
($body:expr) => {
|
||||||
pub(crate) fn router() -> axum::Router<()> {
|
pub(crate) fn router() -> axum::Router {
|
||||||
$body
|
$body
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -104,6 +104,6 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_join_routes() {
|
fn test_join_routes() {
|
||||||
let _router: Router<()> = join_routes![Router::new(), Router::new()];
|
let _router: Router = join_routes![Router::new(), Router::new()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user