I am exploring the capabilities of the Iron web framework. As far as I have figured out, the Iron core doesn't have an API to handle HTTP parameters so I tried to use the params crate.
error: the trait bound `params::Params: plugin::Plugin<iron::Request<'_, '_>>` is not satisfied [E0277]
let map = req.get_ref::<Params>().unwrap();
^~~~~~~
help: run `rustc --explain E0277` to see a detailed explanation
I haven't found trace of this bug and don't have a clue how to fix it.
extern crate iron;
extern crate params;
use iron::prelude::*;
use iron::status;
use params::*; //{self, Params, Value};
fn handle_user(req: &mut Request) -> 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)),
}
}
fn main() {
Iron::new(handle_user).http("localhost:2330").unwrap();
}
Versions of libraries
iron = "0.4.0"
params = "0.2.2"