mirror of https://github.com/fafhrd91/actix-web
Merge 7f9d2471d1
into 7243c58fce
This commit is contained in:
commit
4bb0f54068
|
@ -318,6 +318,23 @@ impl<S> App<S> where S: 'static {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn named_resource<F>(mut self, name: &str, path: &str, f: F) -> App<S>
|
||||||
|
where F: FnOnce(&mut ResourceHandler<S>) + 'static
|
||||||
|
{
|
||||||
|
{
|
||||||
|
let parts = self.parts.as_mut().expect("Use after finish");
|
||||||
|
|
||||||
|
// add resource
|
||||||
|
let mut resource = ResourceHandler::default();
|
||||||
|
resource.name(name);
|
||||||
|
f(&mut resource);
|
||||||
|
|
||||||
|
let pattern = Resource::new(resource.get_name(), path);
|
||||||
|
parts.resources.push((pattern, Some(resource)));
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Default resource is used if no matched route could be found.
|
/// Default resource is used if no matched route could be found.
|
||||||
pub fn default_resource<F, R>(mut self, f: F) -> App<S>
|
pub fn default_resource<F, R>(mut self, f: F) -> App<S>
|
||||||
where F: FnOnce(&mut ResourceHandler<S>) -> R + 'static
|
where F: FnOnce(&mut ResourceHandler<S>) -> R + 'static
|
||||||
|
|
Loading…
Reference in New Issue