I just added a new JsonBodyParser middleware to floor. I think it's usage is pretty straight forward:
#[deriving(Decodable, Encodable)]
pub struct Person {
pub firstname: String,
pub lastname: String,
}
let mut server = Floor::new();
server.utilize(Floor::json_body_parser();
fn post_handler (request: &Request, response: &mut Response) {
let person = request.json_as::<Person>().unwrap();
let text = format!("Hello {} {}", person.firstname, person.lastname);
response.send(text.as_slice());
};
server.post("/a/post/request", post_handler);
One can simply test that out with the example using curl curl 'http://localhost:6767/a/post/request' -H 'Content-Type: application/json;charset=UTF-8' --data-binary $'{ "firstname": "John","lastname": "Connor" }'
Jump to documentation: http://floor-org.github.io/floor/struct.Floor.html#method.json_body_parserRepository: https://github.com/floor-org/floor