pub struct Handler { /* private fields */ }Expand description
Route handler.
You don’t have to use methods below to create route handlers. Rwf provides handy macros which make this experience more ergonomic.
Implementations§
Source§impl Handler
impl Handler
Sourcepub fn new(
path: &str,
controller: impl Controller + 'static,
path_type: PathType,
) -> Self
pub fn new( path: &str, controller: impl Controller + 'static, path_type: PathType, ) -> Self
Create new route handler for the specified path, controller and path type.
Sourcepub fn rest(path: &str, controller: impl Controller + 'static) -> Self
pub fn rest(path: &str, controller: impl Controller + 'static) -> Self
Create a REST route handler. This creates several routes that all map to the same controller, supporting all 6 REST verbs.
Use the rest! macro instead:
ⓘ
rest!("/users" => UsersController)Sourcepub fn wildcard(path: &str, controller: impl Controller + 'static) -> Self
pub fn wildcard(path: &str, controller: impl Controller + 'static) -> Self
Create a REST route handling this and all child paths.
This is useful to create catch-all routes.
Sourcepub fn route(path: &str, controller: impl Controller + 'static) -> Self
pub fn route(path: &str, controller: impl Controller + 'static) -> Self
Sourcepub fn path_with_regex(&self) -> &PathWithRegex
pub fn path_with_regex(&self) -> &PathWithRegex
Get the path and its correspoding regex, used in the router.
Sourcepub fn with_rank(self, rank: i64) -> Self
pub fn with_rank(self, rank: i64) -> Self
Add a rank to the handler, overring its default hierarchy in the router.
Sourcepub fn controller_name(&self) -> &'static str
pub fn controller_name(&self) -> &'static str
Get the controller name served by this route handler.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Handler
impl !RefUnwindSafe for Handler
impl Send for Handler
impl Sync for Handler
impl Unpin for Handler
impl !UnwindSafe for Handler
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