From 173bbc2ca51fea85b7d7a5cfdf4d3f6ee657833e Mon Sep 17 00:00:00 2001 From: Martin Berg Alstad Date: Fri, 28 Jun 2024 19:16:40 +0200 Subject: [PATCH] Adde route method to builder for single route. Removed state () from Router --- src/axum/app.rs | 5 +++++ src/axum/router.rs | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/axum/app.rs b/src/axum/app.rs index 91e1557..b90df91 100644 --- a/src/axum/app.rs +++ b/src/axum/app.rs @@ -42,6 +42,11 @@ impl AppBuilder { 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) -> Self { self.router = routes.into_iter().fold(self.router, Router::merge); self diff --git a/src/axum/router.rs b/src/axum/router.rs index f557cac..75f7b7e 100644 --- a/src/axum/router.rs +++ b/src/axum/router.rs @@ -21,7 +21,7 @@ #[cfg(feature = "axum")] macro_rules! router { ($body:expr) => { - pub(crate) fn router() -> axum::Router<()> { + pub(crate) fn router() -> axum::Router { $body } }; @@ -104,6 +104,6 @@ mod tests { #[test] fn test_join_routes() { - let _router: Router<()> = join_routes![Router::new(), Router::new()]; + let _router: Router = join_routes![Router::new(), Router::new()]; } }