doc fixes
This commit is contained in:
25
README.md
25
README.md
@@ -6,18 +6,23 @@
|
|||||||
|
|
||||||
```rust
|
```rust
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern create ureq;
|
extern crate ureq;
|
||||||
|
|
||||||
// sync post request of some json.
|
fn main() {
|
||||||
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.
|
// sync post request of some json.
|
||||||
assert!(resp.unwrap().ok());
|
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() {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Motivation
|
## Motivation
|
||||||
|
|||||||
22
src/lib.rs
22
src/lib.rs
@@ -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
|
||||||
|
|||||||
@@ -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();
|
||||||
///
|
///
|
||||||
|
|||||||
Reference in New Issue
Block a user