Clarify example from README. (#277)

We should include the `fn main() -> Result` part, because people may not
know they need the `-> Result` in order for `?` to work.

Also, I replaced `Accept: text/html` with `Example-Header: header
value`. My thinking is that if someone doesn't know they need to remove
that Accept for non-HTML URLs, they might get unexpected results.
This commit is contained in:
Jacob Hoffman-Andrews
2020-12-12 10:33:30 -08:00
committed by GitHub
parent 1448969dd7
commit 10baf7c051
2 changed files with 14 additions and 11 deletions

View File

@@ -25,10 +25,13 @@ Version 2.0.0 was released recently and changed some APIs. See the [changelog] f
In its simplest form, ureq looks like this:
```rust
let body: String = ureq::get("http://example.com")
.set("Accept", "text/html")
.call()?
.into_string()?;
fn main() -> Result<(), ureq::Error> {
let body: String = ureq::get("http://example.com")
.set("Example-Header", "header value")
.call()?
.into_string()?;
Ok(())
}
```
For more involved tasks, you'll want to create an [Agent]. An Agent