doc fixes
This commit is contained in:
@@ -6,7 +6,9 @@
|
||||
|
||||
```rust
|
||||
#[macro_use]
|
||||
extern create ureq;
|
||||
extern crate ureq;
|
||||
|
||||
fn main() {
|
||||
|
||||
// sync post request of some json.
|
||||
let resp = ureq::post("https://myapi.acme.com/ingest")
|
||||
@@ -17,7 +19,10 @@ let resp = ureq::post("https://myapi.acme.com/ingest")
|
||||
}));
|
||||
|
||||
// .ok() tells if response is 200-299.
|
||||
assert!(resp.unwrap().ok());
|
||||
if resp.ok() {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Motivation
|
||||
|
||||
22
src/lib.rs
22
src/lib.rs
@@ -5,11 +5,31 @@
|
||||
//! * Minimal dependency tree
|
||||
//! * Obvious API
|
||||
//!
|
||||
//! ```
|
||||
//! #[macro_use]
|
||||
//! extern crate ureq;
|
||||
//!
|
||||
//! fn main() {
|
||||
//! // sync post request of some json.
|
||||
//! let resp = ureq::post("https://myapi.acme.com/ingest")
|
||||
//! .set("X-My-Header", "Secret")
|
||||
//! .send_json(json!({
|
||||
//! "name": "martin",
|
||||
//! "rust": true
|
||||
//! }));
|
||||
//!
|
||||
//! // .ok() tells if response is 200-299.
|
||||
//! if resp.ok() {
|
||||
//! // ....
|
||||
//! }
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! # Plain requests
|
||||
//!
|
||||
//! Most standard methods (GET, POST, PUT etc), are supported as functions from the
|
||||
//! top of the library ([`ureq::get`](fn.get.html), [`ureq::post`](fn.post.html),
|
||||
//! [`ureq::put`](fn.out.html), etc).
|
||||
//! [`ureq::put`](fn.put.html), etc).
|
||||
//!
|
||||
//! These top level http method functions create a [Request](struct.Request.html) instance
|
||||
//! which follows a build pattern. The builders are finished using
|
||||
|
||||
@@ -136,7 +136,8 @@ impl Response {
|
||||
/// Tells if this response is "synthetic".
|
||||
///
|
||||
/// The [methods](struct.Request.html#method.call) [firing](struct.Request.html#method.send)
|
||||
/// [off](struct.Request.html#method.send_string) [requests](struct.Request.html#method.send_json)
|
||||
/// [off](struct.Request.html#method.send_string)
|
||||
/// [requests](struct.Request.html#method.send_json)
|
||||
/// all return a `Response`; there is no rust style `Result`.
|
||||
///
|
||||
/// Rather than exposing a custom error type through results, this library has opted
|
||||
@@ -150,7 +151,8 @@ impl Response {
|
||||
/// The specific mapping of error to code can be seen in the [`Error`](enum.Error.html) doc.
|
||||
///
|
||||
/// However if the distinction is important, this method can be used to tell. Also see
|
||||
/// [error()](struct.Response.html#method.synthetic_error) to see the actual underlying error.
|
||||
/// [synthetic_error()](struct.Response.html#method.synthetic_error)
|
||||
/// to see the actual underlying error.
|
||||
///
|
||||
/// ```
|
||||
/// // scheme that this library doesn't understand
|
||||
@@ -291,7 +293,7 @@ impl Response {
|
||||
///
|
||||
/// ```
|
||||
/// let resp =
|
||||
/// ureq::get("https://raw.githubusercontent.com/algesten/ureq/master/src/test/hello_world.json").call();
|
||||
/// ureq::get("https://s3.amazonaws.com/foosrvr/hello_world.json").call();
|
||||
///
|
||||
/// let json = resp.into_json().unwrap();
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user