Middleware for json or jsonp response with Iron
framework. Both rustc_serialize (default
feature) and serde (feature
serde_type
, no default features) are supported.
Middleware setup:
```rust extern crate ironjsonresponse as ijr; use ijr::{JsonResponseMiddleware, JsonResponse};
let mut chain = Chain::new(...); chain.link_after(JsonResponseMiddleware{}); ... ```
Send json data:
```rust
fn handler(req: &mut Request) -> IronResult
resp.set_mut(JsonResponse::json(data)).set_mut(status::Ok);
Ok(resp)
} ```
Send json data via jsonp:
```rust
fn handler(req: &mut Request) -> IronResult
resp.set_mut(JsonResponse::jsonp(data, "cb".to_owned())).set_mut(status::Ok);
Ok(resp)
} ```
Licensed under either of
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.