Skip to content

Commit

Permalink
async/request: add a basic example for send()
Browse files Browse the repository at this point in the history
  • Loading branch information
lucab authored and seanmonstar committed Feb 15, 2019
1 parent 8b62f47 commit 0c84e6b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/async_impl/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,26 @@ impl RequestBuilder {
///
/// This method fails if there was an error while sending request,
/// redirect loop was detected or redirect limit was exhausted.
///
/// # Example
///
/// ```no_run
/// # extern crate futures;
/// # extern crate reqwest;
/// #
/// # use reqwest::Error;
/// # use futures::future::Future;
/// #
/// # fn run() -> Result<(), Error> {
/// let response = reqwest::r#async::Client::new()
/// .get("https://hyper.rs")
/// .send()
/// .map(|resp| println!("status: {}", resp.status()));
///
/// let mut rt = tokio::runtime::current_thread::Runtime::new().expect("new rt");
/// rt.block_on(response)
/// # }
/// ```
pub fn send(self) -> impl Future<Item = Response, Error = ::Error> {
match self.request {
Ok(req) => self.client.execute(req),
Expand Down

0 comments on commit 0c84e6b

Please sign in to comment.