pub trait Route {
type State: Clone + Send + Sync + 'static;
// Required methods
fn attach(
&self,
router: Router<Self::State>,
level: usize,
) -> Router<Self::State>;
fn path(&self) -> &'static str;
}
Expand description
A trait for defining a route. All routes must implement this trait
A route is not necessarily an HTTP route, it could be anything that can be attached to a router (for example, a nested router).
You typically use the route_group!
macro to define a route struct that
implements this trait, but you can also do it manually.
Be sure to create a function new
(you can find the signature in the
route_group!
macro)