1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
extern crate curl;
pub extern crate http;
#[cfg(feature = "json")]
extern crate json;
extern crate ringtail;

pub mod body;
pub mod client;
pub mod error;
pub mod options;
mod transport;

pub use body::Body;
pub use client::Client;
pub use error::Error;
pub use options::*;


pub type Request = http::Request<Body>;
pub type Response = http::Response<Body>;


/// Sends a GET request.
pub fn get(uri: &str) -> Result<Response, Error> {
    Client::default().get(uri)
}

/// Sends a POST request.
pub fn post<B: Into<Body>>(uri: &str, body: B) -> Result<Response, Error> {
    Client::default().post(uri, body)
}

/// Sends a PUT request.
pub fn put<B: Into<Body>>(uri: &str, body: B) -> Result<Response, Error> {
    Client::default().put(uri, body)
}

/// Sends a DELETE request.
pub fn delete(uri: &str) -> Result<Response, Error> {
    Client::default().delete(uri)
}

pub fn send(request: Request) -> Result<Response, Error> {
    Client::default().send(request)
}