9 releases (5 breaking)

Uses old Rust 2015

0.6.1 Oct 4, 2016
0.5.0 Jun 30, 2016
0.4.2 Jan 26, 2016
0.4.1 Sep 13, 2015
0.2.0 Jul 23, 2015

#142 in #rest

25 downloads per month

MIT/Apache

11KB
197 lines

Ease - HTTP clients for Rust Build Status

Ease is a library for interacting with RESTful APIs.

Examples

In Cargo.toml, put:

[dependencies]
ease = "*"

Make a GET request and print the result:

extern crate ease;

use ease::{Url, Request};

fn main() {
    let url = Url::parse("http://httpbin.org/get").unwrap();
    println!("{}", Request::new(url).param("foo", "bar").get().unwrap().body);
}

Make a POST request and deserialize the response from JSON using serde:

#![feature(custom_derive, plugin)]
#![plugin(serde_macros)]

extern crate ease;

use std::collections::HashMap;
use ease::{Url, Request};

#[derive(Deserialize, Debug)]
struct PostResponse {
    args: HashMap<String, String>,
    data: Option<String>,
    files: Option<HashMap<String, String>>,
    form: Option<HashMap<String, String>>,
    headers: HashMap<String, String>,
    json: Option<String>,
    origin: String,
    url: String,
}

fn main() {
    let url = Url::parse("http://httpbin.org/post").unwrap();
    println!("{:#?}", Request::new(url).post().and_then(|res| res.from_json::<PostResponse>()));
}

Documentation

Documentation is available online and can be built with cargo doc for a local copy.

License

Licensed under either of

at your option.

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

~6MB
~142K SLoC