1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-30 18:44:35 +01:00

fix nested resources

This commit is contained in:
Nikolay Kim 2019-03-06 19:27:18 -08:00
parent 244fff9e0a
commit 60c048c8cd
3 changed files with 7 additions and 11 deletions

View File

@ -32,8 +32,6 @@ use crate::{HttpMessage, HttpResponse};
/// %a "%r" %s %b "%{Referer}i" "%{User-Agent}i" %T /// %a "%r" %s %b "%{Referer}i" "%{User-Agent}i" %T
/// ``` /// ```
/// ```rust /// ```rust
/// # extern crate actix_web;
/// extern crate env_logger;
/// use actix_web::middleware::Logger; /// use actix_web::middleware::Logger;
/// use actix_web::App; /// use actix_web::App;
/// ///
@ -43,8 +41,7 @@ use crate::{HttpMessage, HttpResponse};
/// ///
/// let app = App::new() /// let app = App::new()
/// .middleware(Logger::default()) /// .middleware(Logger::default())
/// .middleware(Logger::new("%a %{User-Agent}i")) /// .middleware(Logger::new("%a %{User-Agent}i"));
/// .finish();
/// } /// }
/// ``` /// ```
/// ///

View File

@ -283,7 +283,7 @@ where
} else { } else {
Some(std::mem::replace(&mut self.guards, Vec::new())) Some(std::mem::replace(&mut self.guards, Vec::new()))
}; };
let rdef = if config.is_root() { let rdef = if config.is_root() || !self.rdef.is_empty() {
ResourceDef::new(&insert_slash(&self.rdef)) ResourceDef::new(&insert_slash(&self.rdef))
} else { } else {
ResourceDef::new(&self.rdef) ResourceDef::new(&self.rdef)

View File

@ -262,12 +262,11 @@ where
} else { } else {
Some(self.guards) Some(self.guards)
}; };
let rdef = if config.is_root() { config.register_service(
ResourceDef::root_prefix(&self.rdef) ResourceDef::root_prefix(&self.rdef),
} else { guards,
ResourceDef::prefix(&self.rdef) self.endpoint,
}; )
config.register_service(rdef, guards, self.endpoint)
} }
} }