doc fixes

This commit is contained in:
Martin Algesten
2018-06-22 10:49:03 +02:00
parent 9fcf77a9a3
commit 72bcbe45db
3 changed files with 41 additions and 14 deletions

View File

@@ -6,7 +6,9 @@
```rust ```rust
#[macro_use] #[macro_use]
extern create ureq; extern crate ureq;
fn main() {
// sync post request of some json. // sync post request of some json.
let resp = ureq::post("https://myapi.acme.com/ingest") 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. // .ok() tells if response is 200-299.
assert!(resp.unwrap().ok()); if resp.ok() {
// ...
}
}
``` ```
## Motivation ## Motivation

View File

@@ -5,11 +5,31 @@
//! * Minimal dependency tree //! * Minimal dependency tree
//! * Obvious API //! * 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 //! # Plain requests
//! //!
//! Most standard methods (GET, POST, PUT etc), are supported as functions from the //! 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), //! 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 //! These top level http method functions create a [Request](struct.Request.html) instance
//! which follows a build pattern. The builders are finished using //! which follows a build pattern. The builders are finished using

View File

@@ -136,7 +136,8 @@ impl Response {
/// Tells if this response is "synthetic". /// Tells if this response is "synthetic".
/// ///
/// The [methods](struct.Request.html#method.call) [firing](struct.Request.html#method.send) /// 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`. /// all return a `Response`; there is no rust style `Result`.
/// ///
/// Rather than exposing a custom error type through results, this library has opted /// 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. /// 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 /// 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 /// // scheme that this library doesn't understand
@@ -291,7 +293,7 @@ impl Response {
/// ///
/// ``` /// ```
/// let resp = /// 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(); /// let json = resp.into_json().unwrap();
/// ///