You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Multipart form data (Content-Type: multipart/form-data)
This plugin combines all request parameters from these sources into a single params::Map accessible through any Iron request using req.get_ref::<params::Params>(). Working example:
// Visit `https://127.0.0.1:3000/?user[name]=Marie` to be greeted with a welcome message. Any other// request will return a 404 error.externcrate iron;externcrate params;use iron::prelude::*;fnhandle_user(req:&mutRequest) -> IronResult<Response>{use params::{Params,Value};let map = req.get_ref::<Params>().unwrap();match map.find(&["user","name"]){Some(&Value::String(ref name))if name == "Marie" => {Ok(Response::with((iron::status::Ok,"Welcome back, Marie!")))},
_ => Ok(Response::with(iron::status::NotFound)),}}fnmain(){Iron::new(handle_user).http("127.0.0.1:3000").unwrap();}
You can perform custom request parameter deserialization by implementing params::FromValue for any Sized type. See src/conversion.rs for inspiration!
Unless you explicitly state otherwise, any contribution intentionally
submitted for inclusion in the work by you, as defined in the Apache-2.0
license, shall be dual licensed as above, without any additional terms or
conditions.