pub struct Intercept {
pub temp_dir_path: Option<PathBuf>,
pub file_size_limit: u64,
pub file_count_limit: u32,
pub limit_behavior: LimitBehavior,
}
Expand description
A BeforeMiddleware
for Iron which will intercept and read-out multipart requests and store
the result in the request.
Successful reads will be placed in the extensions: TypeMap
field of iron::Request
as an
Entries
instance (as both key-type and value):
extern crate iron;
extern crate qiniu_multipart;
use iron::prelude::*;
use qiniu_multipart::server::Entries;
use qiniu_multipart::server::iron::Intercept;
fn main() {
let mut chain = Chain::new(|req: &mut Request| if let Some(entries) =
req.extensions.get::<Entries>() {
Ok(Response::with(format!("{:?}", entries)))
} else {
Ok(Response::with("Not a multipart request"))
});
chain.link_before(Intercept::default());
Iron::new(chain).http("localhost:80").unwrap();
}
Any errors during which occur during reading will be passed on as IronError
.
Fields§
§temp_dir_path: Option<PathBuf>
The parent directory for all temporary directories created by this middleware. Will be created if it doesn’t exist (lazy).
If omitted, uses the OS temporary directory.
Default value: None
.
file_size_limit: u64
The size limit of uploaded files, in bytes.
Files which exceed this size will be rejected.
See the limit_behavior
field for more info.
Default value: DEFAULT_FILE_SIZE_LIMIT
file_count_limit: u32
The limit on the number of files which will be saved from the request. Requests which exceed this count will be rejected.
Default value: DEFAULT_FILE_COUNT_LIMT
limit_behavior: LimitBehavior
What to do when a file count or size limit has been exceeded.
See LimitBehavior
for more info.
Implementations§
Source§impl Intercept
impl Intercept
Sourcepub fn temp_dir_path<P: Into<PathBuf>>(self, path: P) -> Self
pub fn temp_dir_path<P: Into<PathBuf>>(self, path: P) -> Self
Set the temp_dir_path
for this middleware.
Sourcepub fn file_size_limit(self, limit: u64) -> Self
pub fn file_size_limit(self, limit: u64) -> Self
Set the file_size_limit
for this middleware.
Sourcepub fn file_count_limit(self, limit: u32) -> Self
pub fn file_count_limit(self, limit: u32) -> Self
Set the file_count_limit
for this middleware.
Sourcepub fn limit_behavior(self, behavior: LimitBehavior) -> Self
pub fn limit_behavior(self, behavior: LimitBehavior) -> Self
Set the limit_behavior
for this middleware.