Trait axum_extra::routing::RouterExt
source · [−]pub trait RouterExt<B>: Sealed {
fn with<T>(self, routes: T) -> Self
where
T: HasRoutes<B>;
fn typed_get<H, T, P>(self, handler: H) -> Self
where
H: Handler<T, B>,
T: FirstElementIs<P> + 'static,
P: TypedPath;
fn typed_delete<H, T, P>(self, handler: H) -> Self
where
H: Handler<T, B>,
T: FirstElementIs<P> + 'static,
P: TypedPath;
fn typed_head<H, T, P>(self, handler: H) -> Self
where
H: Handler<T, B>,
T: FirstElementIs<P> + 'static,
P: TypedPath;
fn typed_options<H, T, P>(self, handler: H) -> Self
where
H: Handler<T, B>,
T: FirstElementIs<P> + 'static,
P: TypedPath;
fn typed_patch<H, T, P>(self, handler: H) -> Self
where
H: Handler<T, B>,
T: FirstElementIs<P> + 'static,
P: TypedPath;
fn typed_post<H, T, P>(self, handler: H) -> Self
where
H: Handler<T, B>,
T: FirstElementIs<P> + 'static,
P: TypedPath;
fn typed_put<H, T, P>(self, handler: H) -> Self
where
H: Handler<T, B>,
T: FirstElementIs<P> + 'static,
P: TypedPath;
fn typed_trace<H, T, P>(self, handler: H) -> Self
where
H: Handler<T, B>,
T: FirstElementIs<P> + 'static,
P: TypedPath;
}
Expand description
Extension trait that adds additional methods to Router
.
Required methods
Add the routes from T
’s HasRoutes::routes
to this router.
Example
Using Resource
which implements HasRoutes
:
use axum::{Router, routing::get};
use axum_extra::routing::{RouterExt, Resource};
let app = Router::new()
.with(
Resource::named("users")
.index(|| async {})
.create(|| async {})
)
.with(
Resource::named("teams").index(|| async {})
);