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]

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")});

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")});

Trait Implementations