pub struct Router { /* private fields */ }
Expand description
A Struct responsible of dispatching request towards controllers
Implementations
sourceimpl Router
impl Router
sourcepub fn dispatch(&self, req: &mut SyncRequest, res: &mut SyncResponse)
pub fn dispatch(&self, req: &mut SyncRequest, res: &mut SyncResponse)
sourcepub fn add<C: 'static + Controller>(&self, controller: C)
pub fn add<C: 'static + Controller>(&self, controller: C)
Add a new controller with its route to the router
Example
let u8_context = 1;
let u8_controller = BasicController::new(u8_context);
u8_controller.add(Method::Get, "^/test$", |ctx, req, res| { println!("this will handle Get request done on <your_host>/test")});
let mut router = Router::new();
router.add("/test", u8_controller);
sourcepub fn route<C: 'static + Controller, R: ToRegex>(&self, route: R, controller: C)
pub fn route<C: 'static + Controller, R: ToRegex>(&self, route: R, controller: C)
Add a new controller with its route to the router
Example
let u8_context = 1;
let u8_controller = BasicController::new(u8_context);
u8_controller.add(Method::Get, "^/test$", |ctx, req, res| { println!("this will handle Get request done on <your_host>/test")});
let mut router = Router::new();
router.add("/test", u8_controller);
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Router
impl Send for Router
impl Sync for Router
impl Unpin for Router
impl !UnwindSafe for Router
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more