docs(lib): Document available features and update example
This commit is contained in:
		
							parent
							
								
									de16d9698d
								
							
						
					
					
						commit
						b493bc3c84
					
				
					 1 changed files with 20 additions and 7 deletions
				
			
		
							
								
								
									
										27
									
								
								src/lib.rs
									
										
									
									
									
								
							
							
						
						
									
										27
									
								
								src/lib.rs
									
										
									
									
									
								
							|  | @ -9,22 +9,21 @@ | ||||||
| //! dependencies or sacrificing too much usability.
 | //! dependencies or sacrificing too much usability.
 | ||||||
| //!
 | //!
 | ||||||
| //! Using `crimp` to make HTTP requests is done using a simple
 | //! 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
 | //! ```rust
 | ||||||
| //! use crimp::{Method, Request};
 | //! use crimp::{Method, Request};
 | ||||||
| //!
 | //!
 | ||||||
| //! let response = Request::new(Method::Get, "http://httpbin.org/get")
 | //! let response = Request::new(Method::Get, "http://httpbin.org/get")
 | ||||||
| //!     .user_agent("crimp test suite").unwrap()
 | //!     .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
 | //! If a feature from the underlying cURL library is missing, the
 | ||||||
| //! `Request::raw` method can be used as an escape hatch to deal with
 | //! `Request::raw` method can be used as an escape hatch to deal with
 | ||||||
| //! the handle directly. Should you find yourself doing this, please
 | //! 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
 | //! cURL Easy handle, meaning that keep-alive of HTTP connections and
 | ||||||
| //! the like is not supported.
 | //! 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
 | //! [cURL Rust bindings]: https://docs.rs/curl
 | ||||||
| //! [reqwest]: https://docs.rs/reqwest
 | //! [reqwest]: https://docs.rs/reqwest
 | ||||||
| //! [file an issue]: https://github.com/tazjin/crimp/issues
 | //! [file an issue]: https://github.com/tazjin/crimp/issues
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue