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 multipart;
use iron::prelude::*;
use multipart::server::Entries;
use 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
.
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
.
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
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
What to do when a file count or size limit has been exceeded.
See LimitBehavior
for more info.
Set the temp_dir_path
for this middleware.
Set the file_size_limit
for this middleware.
Set the file_count_limit
for this middleware.
Set the limit_behavior
for this middleware.
Returns the "default value" for a type. Read more
Formats the value using the given formatter. Read more
Do whatever work this middleware should do with a Request
object.
Respond to an error thrown by a previous BeforeMiddleware
. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
impl<T> Typeable for T where T: Any, | |
Get the TypeId
of this object.
Do whatever work this middleware should do with a Request
object.
Respond to an error thrown by a previous BeforeMiddleware
. Read more
impl<T> DebugAny for T where T: Any + Debug, | |
impl<T> UnsafeAny for T where T: Any, | |