Struct saphir::ControllerDispatch [−][src]
pub struct ControllerDispatch<T> { /* fields omitted */ }
Struct to delegate a request to a registered function matching booth a method
and a path
Methods
impl<T: Send + Sync> ControllerDispatch<T>
[src]
impl<T: Send + Sync> ControllerDispatch<T>
pub fn new(delegate_context: T) -> Self
[src]
pub fn new(delegate_context: T) -> Self
pub fn add<F, R: ToRegex>(&self, method: Method, path: R, delegate_func: F) where
F: 'static + Fn(&'r T, &'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 T, &'s SyncRequest, &'t0 mut SyncResponse),
Add a delegate function to handle a particular request
Example
let u8_context = 1; let dispatch = ControllerDispatch::new(u8_context); dispatch.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 T, &'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 T, &'s SyncRequest, &'t0 mut SyncResponse),
Add a delegate function to handle a particular request
Example
let u8_context = 1; let guard = BodyGuard; let dispatch = ControllerDispatch::new(u8_context); dispatch.add_with_guards(Method::Get, "^/test$", guard.into(), |ctx, req, res| { println!("this will handle Get request done on <your_host>/test")});
pub fn dispatch(&self, req: &mut SyncRequest, res: &mut SyncResponse)
[src]
pub fn dispatch(&self, req: &mut SyncRequest, res: &mut SyncResponse)
Trait Implementations
impl<T> Sync for ControllerDispatch<T>
[src]
impl<T> Sync for ControllerDispatch<T>
impl<T> Send for ControllerDispatch<T>
[src]
impl<T> Send for ControllerDispatch<T>