about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2019-02-26T15·47+0100
committerVincent Ambo <mail@tazj.in>2019-02-26T16·30+0100
commitb493bc3c8436be9812a58e7ddaf3777df642836c (patch)
tree3848c1fdf8898e6addee181222d5344ae6da84db /src
parentde16d9698db4ea851464d3f3c49f51c97dcbdf03 (diff)
docs(lib): Document available features and update example
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 9374460d2428..90c216dc7497 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -9,22 +9,21 @@
 //! dependencies or sacrificing too much usability.
 //!
 //! Using `crimp` to make HTTP requests is done using a simple
-//! builder-pattern style API:
+//! builder-pattern style API. For example, to make a `GET`-request
+//! and print the result to `stdout`:
 //!
 //! ```rust
 //! use crimp::{Method, Request};
 //!
 //! let response = Request::new(Method::Get, "http://httpbin.org/get")
 //!     .user_agent("crimp test suite").unwrap()
-//!     .send().unwrap();
+//!     .send().unwrap()
+//!     .as_string().unwrap();
 //!
-//! assert_eq!(response.status, 200);
+//! println!("Status: {}\nBody: {}", response.status, response.body);
+//! # assert_eq!(response.status, 200);
 //! ```
 //!
-//! The `json` feature (enabled by default) adds support for
-//! automatically serialising and deserialising request/response
-//! bodies using `serde_json`.
-//!
 //! If a feature from the underlying cURL library is missing, the
 //! `Request::raw` method can be used as an escape hatch to deal with
 //! the handle directly. Should you find yourself doing this, please
@@ -34,6 +33,20 @@
 //! cURL Easy handle, meaning that keep-alive of HTTP connections and
 //! the like is not supported.
 //!
+//! ## Cargo features
+//!
+//! `crimp` has several optional features, all of which are enabled by
+//! default:
+//!
+//! * `json`: Adds `Request::json` and `Response::as_json` methods
+//!   which can be used for convenient serialisation of
+//!   request/response bodies using `serde_json`. This feature adds a
+//!   dependency on the `serde` and `serde_json` crates.
+//!
+//! * `basic_auth`: Adds a `Request::basic_auth` utility method to set
+//!   a basic authentication header on the request. This feature adds
+//!   a dependency on the `base64` crate.
+//!
 //! [cURL Rust bindings]: https://docs.rs/curl
 //! [reqwest]: https://docs.rs/reqwest
 //! [file an issue]: https://github.com/tazjin/crimp/issues