diff --git a/actix-files/src/files.rs b/actix-files/src/files.rs index adfb9323..a30ce6fd 100644 --- a/actix-files/src/files.rs +++ b/actix-files/src/files.rs @@ -37,7 +37,7 @@ use crate::{ /// .service(Files::new("/static", ".")); /// ``` pub struct Files { - path: String, + mount_path: String, directory: PathBuf, index: Option, show_index: bool, @@ -68,7 +68,7 @@ impl Clone for Files { default: self.default.clone(), renderer: self.renderer.clone(), file_flags: self.file_flags, - path: self.path.clone(), + mount_path: self.mount_path.clone(), mime_override: self.mime_override.clone(), path_filter: self.path_filter.clone(), use_guards: self.use_guards.clone(), @@ -107,7 +107,7 @@ impl Files { }; Files { - path: mount_path.trim_end_matches('/').to_owned(), + mount_path: mount_path.trim_end_matches('/').to_owned(), directory: dir, index: None, show_index: false, @@ -342,9 +342,9 @@ impl HttpServiceFactory for Files { } let rdef = if config.is_root() { - ResourceDef::root_prefix(&self.path) + ResourceDef::root_prefix(&self.mount_path) } else { - ResourceDef::prefix(&self.path) + ResourceDef::prefix(&self.mount_path) }; config.register_service(rdef, guards, self, None) diff --git a/actix-files/src/service.rs b/actix-files/src/service.rs index 5d494f87..ec09af01 100644 --- a/actix-files/src/service.rs +++ b/actix-files/src/service.rs @@ -168,7 +168,7 @@ impl Service for FilesService { } } None if this.show_index => Ok(this.show_index(req, path)), - _ => Ok(ServiceResponse::from_err( + None => Ok(ServiceResponse::from_err( FilesError::IsDirectory, req.into_parts().0, )), diff --git a/src/types/path.rs b/src/types/path.rs index c3efc22c..58a1a5bd 100644 --- a/src/types/path.rs +++ b/src/types/path.rs @@ -1,9 +1,10 @@ //! For path segment extractor documentation, see [`Path`]. -use std::{fmt, ops, sync::Arc}; +use std::sync::Arc; use actix_router::PathDeserializer; use actix_utils::future::{ready, Ready}; +use derive_more::{AsRef, Deref, DerefMut, Display, From}; use serde::de; use crate::{ @@ -49,7 +50,9 @@ use crate::{ /// format!("Welcome {}!", info.name) /// } /// ``` -#[derive(PartialEq, Eq, PartialOrd, Ord, Debug)] +#[derive( + Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Deref, DerefMut, AsRef, Display, From, +)] pub struct Path(T); impl Path { @@ -59,38 +62,6 @@ impl Path { } } -impl AsRef for Path { - fn as_ref(&self) -> &T { - &self.0 - } -} - -impl ops::Deref for Path { - type Target = T; - - fn deref(&self) -> &T { - &self.0 - } -} - -impl ops::DerefMut for Path { - fn deref_mut(&mut self) -> &mut T { - &mut self.0 - } -} - -impl From for Path { - fn from(inner: T) -> Path { - Path(inner) - } -} - -impl fmt::Display for Path { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.0.fmt(f) - } -} - /// See [here](#Examples) for example of usage as an extractor. impl FromRequest for Path where