docs: provide basic auth example (#1362)

This commit is contained in:
Karsten Jeschkies
2021-10-22 00:08:53 +02:00
committed by GitHub
parent 59bc9a9323
commit be8ab7b951

View File

@@ -228,6 +228,19 @@ impl RequestBuilder {
}
/// Enable HTTP basic authentication.
///
/// ```rust
/// # use reqwest::Error;
///
/// # async fn run() -> Result<(), Error> {
/// let client = reqwest::Client::new();
/// let resp = client.delete("http://httpbin.org/delete")
/// .basic_auth("admin", Some("good password"))
/// .send()
/// .await?;
/// # Ok(())
/// # }
/// ```
pub fn basic_auth<U, P>(self, username: U, password: Option<P>) -> RequestBuilder
where
U: fmt::Display,