Skip to content

Commit

Permalink
Update example to be something that works when run
Browse files Browse the repository at this point in the history
Also add the README example to examples/ to ensure it keeps working

fixes: #6
  • Loading branch information
bobbobbio committed Sep 9, 2022
1 parent dc8ad83 commit 631ca1d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ use std::io;

fn main() -> Result<()> {
// Stream contents of url to stdout
let mut body = http_io::client::get("http://www.google.com")?;
let mut body = http_io::client::get("https://postman-echo.com/get")?;
io::copy(&mut body, &mut std::io::stdout())?;

// Stream contents of file to remote server
let file = File::open("src/client.rs")?;
http_io::client::put("http://www.google.com", file)?;
http_io::client::put("https://postman-echo.com/put", file)?;
Ok(())
}
```
Expand Down
14 changes: 14 additions & 0 deletions examples/readme.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use http_io::error::Result;
use std::fs::File;
use std::io;

fn main() -> Result<()> {
// Stream contents of url to stdout
let mut body = http_io::client::get("https://postman-echo.com/get")?;
io::copy(&mut body, &mut std::io::stdout())?;

// Stream contents of file to remote server
let file = File::open("src/client.rs")?;
http_io::client::put("https://postman-echo.com/put", file)?;
Ok(())
}
3 changes: 3 additions & 0 deletions prepush
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ cargo check
cargo test
cargo test --no-default-features --features std,ssl-openssl
cargo test --no-default-features --features std,ssl-rustls

cargo run --example readme
cargo run --example connection_reuse

0 comments on commit 631ca1d

Please sign in to comment.