diff --git a/src/middleware/logger.rs b/src/middleware/logger.rs index 769d8428..d8b4e643 100644 --- a/src/middleware/logger.rs +++ b/src/middleware/logger.rs @@ -32,8 +32,6 @@ use crate::{HttpMessage, HttpResponse}; /// %a "%r" %s %b "%{Referer}i" "%{User-Agent}i" %T /// ``` /// ```rust -/// # extern crate actix_web; -/// extern crate env_logger; /// use actix_web::middleware::Logger; /// use actix_web::App; /// @@ -43,8 +41,7 @@ use crate::{HttpMessage, HttpResponse}; /// /// let app = App::new() /// .middleware(Logger::default()) -/// .middleware(Logger::new("%a %{User-Agent}i")) -/// .finish(); +/// .middleware(Logger::new("%a %{User-Agent}i")); /// } /// ``` /// diff --git a/src/resource.rs b/src/resource.rs index ddcbbcd3..157b181e 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -283,7 +283,7 @@ where } else { 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)) } else { ResourceDef::new(&self.rdef) diff --git a/src/scope.rs b/src/scope.rs index 29f44fc4..5580b15e 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -262,12 +262,11 @@ where } else { Some(self.guards) }; - let rdef = if config.is_root() { - ResourceDef::root_prefix(&self.rdef) - } else { - ResourceDef::prefix(&self.rdef) - }; - config.register_service(rdef, guards, self.endpoint) + config.register_service( + ResourceDef::root_prefix(&self.rdef), + guards, + self.endpoint, + ) } }