add bearer auth to async RequestBuilder (#475)

This commit is contained in:
Frank Benkstein
2019-03-13 19:00:54 +01:00
committed by Sean McArthur
parent a27db28deb
commit 08847cc9f5

View File

@@ -174,6 +174,15 @@ impl RequestBuilder {
self.header(::header::AUTHORIZATION, &*header_value) self.header(::header::AUTHORIZATION, &*header_value)
} }
/// Enable HTTP bearer authentication.
pub fn bearer_auth<T>(self, token: T) -> RequestBuilder
where
T: fmt::Display,
{
let header_value = format!("Bearer {}", token);
self.header(::header::AUTHORIZATION, &*header_value)
}
/// Set the request body. /// Set the request body.
pub fn body<T: Into<Body>>(mut self, body: T) -> RequestBuilder { pub fn body<T: Into<Body>>(mut self, body: T) -> RequestBuilder {
if let Ok(ref mut req) = self.request { if let Ok(ref mut req) = self.request {