Repository: actix/actix-web
File: src/fs.rs (Rust)

Code before:
    index: Option<String>,
    show_index: bool,
    cpu_pool: CpuPool,
    default: Box<RouteHandler<S>>,
    renderer: Box<DirectoryRenderer<S>>,
    _chunk_size: usize,
    _follow_symlinks: bool,
}

impl<S: 'static> StaticFiles<S> {
    /// Create new `StaticFiles` instance for specified base directory.
    ///
    /// `StaticFile` uses `CpuPool` for blocking filesystem operations.
    /// By default pool with 20 threads is used.
    /// Pool size can be changed by setting ACTIX_CPU_POOL environment variable.
    pub fn new<T: Into<PathBuf>>(dir: T) -> StaticFiles<S> {
        // use default CpuPool
        let pool = { DEFAULT_CPUPOOL.lock().clone() };

        StaticFiles::with_pool(dir, pool)
    }

    /// Create new `StaticFiles` instance for specified base directory and
    /// `CpuPool`.
    pub fn with_pool<T: Into<PathBuf>>(dir: T, pool: CpuPool) -> StaticFiles<S> {
        let dir = dir.into();

        let dir = match dir.canonicalize() {
            Ok(dir) => {
                if !dir.is_dir() {
                    warn!("Is not directory `{:?}`", dir);
                };
                dir
            }
            Err(err) => {
                warn!("Static files directory `{:?}` error: {}", dir, err);
                dir
            }
        };

        StaticFiles {
            directory: dir,
            index: None,
            show_index: false,
            cpu_pool: pool,
            default: Box::new(WrapHandler::new(|_| {
                HttpResponse::new(StatusCode::NOT_FOUND)
            })),
            renderer: Box::new(directory_listing),
            _chunk_size: 0,
            _follow_symlinks: false,

Review comment (refactor):
Now I think about it, maybe we should refactor it to return error to user instead of keeping it as it is

@fafhrd91 You wouldn't mind to change this API?

Code after:
    _chunk_size: usize,
    _follow_symlinks: bool,
}

impl<S: 'static> StaticFiles<S> {
    /// Create new `StaticFiles` instance for specified base directory.
    ///
    /// `StaticFile` uses `CpuPool` for blocking filesystem operations.
    /// By default pool with 20 threads is used.
    /// Pool size can be changed by setting ACTIX_CPU_POOL environment variable.
    pub fn new<T: Into<PathBuf>>(dir: T) -> Result<StaticFiles<S>, Error> {
        // use default CpuPool
        let pool = { DEFAULT_CPUPOOL.lock().clone() };

        StaticFiles::with_pool(dir, pool)
    }

    /// Create new `StaticFiles` instance for specified base directory and
    /// `CpuPool`.
    pub fn with_pool<T: Into<PathBuf>>(dir: T, pool: CpuPool) -> Result<StaticFiles<S>, Error> {
        let dir = dir.into().canonicalize()?;

        if !dir.is_dir() {
            return Err(StaticFileError::IsNotDirectory.into())
        }

        Ok(StaticFiles {
            directory: dir,
            index: None,
            show_index: false,
            cpu_pool: pool,
            default: Box::new(WrapHandler::new(|_: &_| {
                HttpResponse::new(StatusCode::NOT_FOUND)
            })),
            renderer: Box::new(directory_listing),
            _chunk_size: 0,
            _follow_symlinks: false,
        })
    }

    /// Show files listing for directories.
    ///
    /// By default show files listing is disabled.
    pub fn show_files_listing(mut self) -> Self {
        self.show_index = true;
        self
    }

    /// Set custom directory renderer
    pub fn files_listing_renderer<F>(mut self, f: F) -> Self
    where