Adde route method to builder for single route.

Removed state () from Router
This commit is contained in:
Martin Berg Alstad 2024-06-28 19:16:40 +02:00
parent cdc8f5e463
commit 173bbc2ca5
2 changed files with 7 additions and 2 deletions

View File

@ -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<Item = Router>) -> Self {
self.router = routes.into_iter().fold(self.router, Router::merge);
self

View File

@ -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()];
}
}