mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-24 00:01:11 +01:00
allow register router resource for ResourceDef
This commit is contained in:
parent
9979bfb3ef
commit
a53f06a1a4
@ -89,7 +89,6 @@ where
|
||||
/// `ApplyNewService` new service combinator
|
||||
pub struct ApplyNewService<T, S>
|
||||
where
|
||||
// T::InitError: From<S::InitError>,
|
||||
T: NewTransform<S::Service, InitError = S::InitError>,
|
||||
T::Error: From<S::Error>,
|
||||
S: NewService,
|
||||
|
@ -115,16 +115,25 @@ pub struct RouterBuilder<T> {
|
||||
}
|
||||
|
||||
impl<T> RouterBuilder<T> {
|
||||
/// Register resource for specified path.
|
||||
pub fn path(&mut self, path: &str, resource: T) {
|
||||
self.rmap.register(ResourceDef::new(path));
|
||||
self.resources.push(resource);
|
||||
}
|
||||
|
||||
/// Register resource for specified path prefix.
|
||||
pub fn prefix(&mut self, prefix: &str, resource: T) {
|
||||
self.rmap.register(ResourceDef::prefix(prefix));
|
||||
self.resources.push(resource);
|
||||
}
|
||||
|
||||
/// Register resource for ResourceDef
|
||||
pub fn rdef(&mut self, rdef: ResourceDef, resource: T) {
|
||||
self.rmap.register(rdef);
|
||||
self.resources.push(resource);
|
||||
}
|
||||
|
||||
/// Finish configuration and create router instance.
|
||||
pub fn finish(self) -> Router<T> {
|
||||
Router {
|
||||
rmap: Rc::new(self.rmap),
|
||||
|
Loading…
Reference in New Issue
Block a user