pub struct AppRoutes { /* private fields */ }
Expand description
Represents the routes of the application.
Implementations§
Source§impl AppRoutes
impl AppRoutes
Sourcepub fn with_default_routes() -> Self
pub fn with_default_routes() -> Self
Create a new instance with the default routes.
pub fn collect(&self) -> Vec<ListRoutes>
Sourcepub fn get_prefix(&self) -> Option<&String>
pub fn get_prefix(&self) -> Option<&String>
Get the prefix of the routes.
Sourcepub fn get_routes(&self) -> &[Routes]
pub fn get_routes(&self) -> &[Routes]
Get the routes.
Sourcepub fn prefix(self, prefix: &str) -> Self
pub fn prefix(self, prefix: &str) -> Self
Set a prefix for the routes. this prefix will be a prefix for all the routes.
§Example
In the following example you are adding api as a prefix for all routes
use loco_rs::controller::AppRoutes;
AppRoutes::with_default_routes().prefix("api");
Sourcepub fn add_routes(self, mounts: Vec<Routes>) -> Self
pub fn add_routes(self, mounts: Vec<Routes>) -> Self
Add multiple routes.
Sourcepub fn to_router(&self, ctx: AppContext) -> Result<AXRouter>
pub fn to_router(&self, ctx: AppContext) -> Result<AXRouter>
Convert the routes to an Axum Router, and set a list of middlewares that
configure in the config::Config
§Errors
Return an Result
when could not convert the router setup to
axum::Router
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AppRoutes
impl RefUnwindSafe for AppRoutes
impl Send for AppRoutes
impl Sync for AppRoutes
impl Unpin for AppRoutes
impl UnwindSafe for AppRoutes
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more