Struct saphir::BasicController
[−]
[src]
pub struct BasicController<C> { /* fields omitted */ }
An helper struct embedding a ControllerDispatch
.
Methods
impl<C: Send + Sync> BasicController<C>
[src]
pub fn new(controller_context: C) -> Self
[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 Response<Body>),
[src]
F: 'static + Fn(&'r C, &'s SyncRequest, &'t0 mut Response<Body>),
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 Response<Body>),
[src]
&self,
method: Method,
path: R,
guards: RequestGuardCollection,
delegate_func: F
) where
F: 'static + Fn(&'r C, &'s SyncRequest, &'t0 mut Response<Body>),
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")});