#json #iron #webdev #web

iron-json-response

Json response middleware for Iron web framework

8 releases (5 breaking)

Uses old Rust 2015

0.6.0 Nov 28, 2017
0.5.1 May 10, 2017
0.4.0 Mar 8, 2017
0.3.0 Jan 29, 2017
0.1.1 Apr 4, 2016

#11 in #webframework

Download history 27/week @ 2023-06-03 66/week @ 2023-06-17 39/week @ 2023-06-24 48/week @ 2023-07-01 24/week @ 2023-07-08 27/week @ 2023-07-15 37/week @ 2023-07-22 16/week @ 2023-07-29 31/week @ 2023-08-05 39/week @ 2023-08-12 21/week @ 2023-08-19 23/week @ 2023-08-26 31/week @ 2023-09-02 41/week @ 2023-09-09 25/week @ 2023-09-16

126 downloads per month
Used in replicante_util_iron

MIT/Apache

7KB
80 lines

Iron Json Response

Build Status

Middleware for json or jsonp response with Iron framework. Using serde for data type and serialization.

Usage

Setup

Middleware setup:

extern crate iron_json_response as ijr;
use ijr::{JsonResponseMiddleware, JsonResponse};

let mut chain = Chain::new(...);
chain.link_after(JsonResponseMiddleware::new());
...

Json

Send json data:

fn handler(req: &mut Request) -> IronResult<Response> {
    let mut resp = Response::new();
    let data = ...

    resp.set_mut(JsonResponse::json(data)).set_mut(status::Ok);
    Ok(resp)
}

Jsonp

Send json data via jsonp:

fn handler(req: &mut Request) -> IronResult<Response> {
    let mut resp = Response::new();
    let data = ...

    resp.set_mut(JsonResponse::jsonp(data, "cb".to_owned())).set_mut(status::Ok);
    Ok(resp)
}

License

Licensed under either of

Contribution

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.

Dependencies

~5.5MB
~140K SLoC