mirror of
https://github.com/actix/actix-web.git
synced 2025-01-16 04:05:39 +00:00
hide ChunkedReadFile
This commit is contained in:
parent
9ab586e24e
commit
5b7740dee3
1 changed files with 12 additions and 5 deletions
17
src/fs.rs
17
src/fs.rs
|
@ -472,6 +472,7 @@ impl<C: StaticFileConfig> Responder for NamedFile<C> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
/// A helper created from a `std::fs::File` which reads the file
|
/// A helper created from a `std::fs::File` which reads the file
|
||||||
/// chunk-by-chunk on a `CpuPool`.
|
/// chunk-by-chunk on a `CpuPool`.
|
||||||
pub struct ChunkedReadFile {
|
pub struct ChunkedReadFile {
|
||||||
|
@ -562,7 +563,8 @@ impl Directory {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn directory_listing<S>(
|
fn directory_listing<S>(
|
||||||
dir: &Directory, req: &HttpRequest<S>,
|
dir: &Directory,
|
||||||
|
req: &HttpRequest<S>,
|
||||||
) -> Result<HttpResponse, io::Error> {
|
) -> Result<HttpResponse, io::Error> {
|
||||||
let index_of = format!("Index of {}", req.path());
|
let index_of = format!("Index of {}", req.path());
|
||||||
let mut body = String::new();
|
let mut body = String::new();
|
||||||
|
@ -656,7 +658,8 @@ impl<S: 'static> StaticFiles<S> {
|
||||||
/// Create new `StaticFiles` instance for specified base directory and
|
/// Create new `StaticFiles` instance for specified base directory and
|
||||||
/// `CpuPool`.
|
/// `CpuPool`.
|
||||||
pub fn with_pool<T: Into<PathBuf>>(
|
pub fn with_pool<T: Into<PathBuf>>(
|
||||||
dir: T, pool: CpuPool,
|
dir: T,
|
||||||
|
pool: CpuPool,
|
||||||
) -> Result<StaticFiles<S>, Error> {
|
) -> Result<StaticFiles<S>, Error> {
|
||||||
Self::with_config_pool(dir, pool, DefaultConfig)
|
Self::with_config_pool(dir, pool, DefaultConfig)
|
||||||
}
|
}
|
||||||
|
@ -667,7 +670,8 @@ impl<S: 'static, C: StaticFileConfig> StaticFiles<S, C> {
|
||||||
///
|
///
|
||||||
/// Identical with `new` but allows to specify configiration to use.
|
/// Identical with `new` but allows to specify configiration to use.
|
||||||
pub fn with_config<T: Into<PathBuf>>(
|
pub fn with_config<T: Into<PathBuf>>(
|
||||||
dir: T, config: C,
|
dir: T,
|
||||||
|
config: C,
|
||||||
) -> Result<StaticFiles<S, C>, Error> {
|
) -> Result<StaticFiles<S, C>, Error> {
|
||||||
// use default CpuPool
|
// use default CpuPool
|
||||||
let pool = { DEFAULT_CPUPOOL.lock().clone() };
|
let pool = { DEFAULT_CPUPOOL.lock().clone() };
|
||||||
|
@ -678,7 +682,9 @@ impl<S: 'static, C: StaticFileConfig> StaticFiles<S, C> {
|
||||||
/// Create new `StaticFiles` instance for specified base directory with config and
|
/// Create new `StaticFiles` instance for specified base directory with config and
|
||||||
/// `CpuPool`.
|
/// `CpuPool`.
|
||||||
pub fn with_config_pool<T: Into<PathBuf>>(
|
pub fn with_config_pool<T: Into<PathBuf>>(
|
||||||
dir: T, pool: CpuPool, _: C,
|
dir: T,
|
||||||
|
pool: CpuPool,
|
||||||
|
_: C,
|
||||||
) -> Result<StaticFiles<S, C>, Error> {
|
) -> Result<StaticFiles<S, C>, Error> {
|
||||||
let dir = dir.into().canonicalize()?;
|
let dir = dir.into().canonicalize()?;
|
||||||
|
|
||||||
|
@ -736,7 +742,8 @@ impl<S: 'static, C: StaticFileConfig> StaticFiles<S, C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_handle(
|
fn try_handle(
|
||||||
&self, req: &HttpRequest<S>,
|
&self,
|
||||||
|
req: &HttpRequest<S>,
|
||||||
) -> Result<AsyncResult<HttpResponse>, Error> {
|
) -> Result<AsyncResult<HttpResponse>, Error> {
|
||||||
let tail: String = req.match_info().query("tail")?;
|
let tail: String = req.match_info().query("tail")?;
|
||||||
let relpath = PathBuf::from_param(tail.trim_left_matches('/'))?;
|
let relpath = PathBuf::from_param(tail.trim_left_matches('/'))?;
|
||||||
|
|
Loading…
Reference in a new issue