Request parameters extension for the Iron web framework.
iron-params is a fast, convenient, and flexible extension for Iron Request. It allows retriving query/form params from iron request and conver into the type you want.
```rust extern crate iron; extern crate iron_params as params; use iron::prelude::; use params::;
// To run, $ cargo run --example simple // to use, $ curl -d "ids=1,2,3&channel=1" "http://localhost:3000/?ids=4,5,6,"
fn main() { let mut chain = Chain::new(handler); chain.link_before(params::Params {}); Iron::new(chain).http("localhost:3000").unwrap(); }
fn handler(req: &mut Request) -> IronResult
let ids = req.params("ids");
content.push_str(&format!("ids:{:?}\n", ids));
let channel = req.param::<i32>("channel");
content.push_str(&format!("channel:{:?}\n", channel));
let channel = req.param::<String>("channel");
content.push_str(&format!("channel:{:?}\n", channel));
Ok(Response::with((iron::status::Ok, content)))
}
```
If you're using cargo, just add router to your Cargo.toml
.
```toml [dependencies]
iron-params = "*" ```
Otherwise, cargo build
, and the rlib will be in your target
directory.