Skip to content

Commit 62be014

Browse files
author
Stjepan Glavina
committed
Bring back surf example
1 parent 5dd0ab0 commit 62be014

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ slab = "0.4.2"
3535

3636
[dev-dependencies]
3737
femme = "1.1.0"
38-
# surf = { git = "ssh://github.com/yoshuawuyts/surf" }
38+
surf = "1.0.1"
3939
tempdir = "0.3.7"

examples/fetch-html.rs

-15
This file was deleted.

examples/surf-web.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//! Creates a web request to the Rust website.
2+
3+
#![feature(async_await)]
4+
5+
use async_std::task;
6+
7+
fn main() -> Result<(), surf::Exception> {
8+
task::block_on(async {
9+
let url = "https://www.rust-lang.org";
10+
let mut response = surf::get(url).await?;
11+
let body = response.body_string().await?;
12+
13+
dbg!(url);
14+
dbg!(response.status());
15+
dbg!(response.version());
16+
dbg!(response.headers());
17+
dbg!(body.len());
18+
19+
Ok(())
20+
})
21+
}

0 commit comments

Comments
 (0)