pub struct Router {
pub tree: PathTree<Box<dyn Fn(Request, Params) -> Response>>,
}
Fields§
§tree: PathTree<Box<dyn Fn(Request, Params) -> Response>>
Implementations§
Source§impl Router
impl Router
pub fn new() -> Router
Sourcepub fn add(
&mut self,
method: &str,
path: &str,
data: Box<dyn Fn(Request, Params) -> Response>,
)
pub fn add( &mut self, method: &str, path: &str, data: Box<dyn Fn(Request, Params) -> Response>, )
Add a new route with method, path and the handler.
Sourcepub fn get(
&mut self,
path: &str,
data: Box<dyn Fn(Request, Params) -> Response>,
)
pub fn get( &mut self, path: &str, data: Box<dyn Fn(Request, Params) -> Response>, )
Add a new route with GET
method.
Sourcepub fn post(
&mut self,
path: &str,
data: Box<dyn Fn(Request, Params) -> Response>,
)
pub fn post( &mut self, path: &str, data: Box<dyn Fn(Request, Params) -> Response>, )
Add a new route with POST
method.
Sourcepub fn put(
&mut self,
path: &str,
data: Box<dyn Fn(Request, Params) -> Response>,
)
pub fn put( &mut self, path: &str, data: Box<dyn Fn(Request, Params) -> Response>, )
Add a new route with PUT
method.
Sourcepub fn patch(
&mut self,
path: &str,
data: Box<dyn Fn(Request, Params) -> Response>,
)
pub fn patch( &mut self, path: &str, data: Box<dyn Fn(Request, Params) -> Response>, )
Add a new route with PATCH
method.
Sourcepub fn delete(
&mut self,
path: &str,
data: Box<dyn Fn(Request, Params) -> Response>,
)
pub fn delete( &mut self, path: &str, data: Box<dyn Fn(Request, Params) -> Response>, )
Add a new route with DELETE
method.
Sourcepub fn connect(
&mut self,
path: &str,
data: Box<dyn Fn(Request, Params) -> Response>,
)
pub fn connect( &mut self, path: &str, data: Box<dyn Fn(Request, Params) -> Response>, )
Add a new route with CONNECT
method.
Sourcepub fn head(
&mut self,
path: &str,
data: Box<dyn Fn(Request, Params) -> Response>,
)
pub fn head( &mut self, path: &str, data: Box<dyn Fn(Request, Params) -> Response>, )
Add a new route with HEAD
method.
Auto Trait Implementations§
impl Freeze for Router
impl !RefUnwindSafe for Router
impl !Send for Router
impl !Sync for Router
impl Unpin for Router
impl !UnwindSafe for Router
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