Struct saphir::BasicController [−][src]
pub struct BasicController<C> { /* fields omitted */ }
An helper struct embedding a ControllerDispatch
.
Methods
impl<C: Send + Sync> BasicController<C>
[src]
impl<C: Send + Sync> BasicController<C>
pub fn new(name: &str, controller_context: C) -> Self
[src]
pub fn new(name: &str, controller_context: C) -> Self
pub fn add<F, R: ToRegex>(&self, method: Method, path: R, delegate_func: F) where
F: 'static + Fn(&'r C, &'s SyncRequest, &'t0 mut SyncResponse),
[src]
pub fn add<F, R: ToRegex>(&self, method: Method, path: R, delegate_func: F) where
F: 'static + Fn(&'r C, &'s SyncRequest, &'t0 mut SyncResponse),
Add a delegate function to handle a particular request
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")});
pub fn add_with_guards<F, R: ToRegex>(
&self,
method: Method,
path: R,
guards: RequestGuardCollection,
delegate_func: F
) where
F: 'static + Fn(&'r C, &'s SyncRequest, &'t0 mut SyncResponse),
[src]
pub fn add_with_guards<F, R: ToRegex>(
&self,
method: Method,
path: R,
guards: RequestGuardCollection,
delegate_func: F
) where
F: 'static + Fn(&'r C, &'s SyncRequest, &'t0 mut SyncResponse),
Add a delegate function to handle a particular request
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")});
Trait Implementations
impl<C: Send + Sync> Controller for BasicController<C>
[src]
impl<C: Send + Sync> Controller for BasicController<C>
fn handle(&self, req: &mut SyncRequest, res: &mut SyncResponse)
[src]
fn handle(&self, req: &mut SyncRequest, res: &mut SyncResponse)
Method invoked if the request gets routed to this controller. Nothing will be processed after a controller handling
a request. When returning from this function, the res
param is the response returned to the client. Read more
fn base_path(&self) -> &str
[src]
fn base_path(&self) -> &str
Method used by the router to know were to route a request addressed at a controller
Auto Trait Implementations
impl<C> Send for BasicController<C>
impl<C> Send for BasicController<C>
impl<C> Sync for BasicController<C>
impl<C> Sync for BasicController<C>