diff options
-rw-r--r-- | src/lib.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs index 027a8cda5b93..56d6327e40bf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -124,11 +124,18 @@ impl <'a> Request<'a> { /// Set the `User-Agent` for this request. By default this will be /// set to cURL's standard user agent. - pub fn user_agent<'b: 'a>(mut self, agent: &str) -> Result<Self, curl::Error> { + pub fn user_agent(mut self, agent: &str) -> Result<Self, curl::Error> { self.handle.useragent(agent)?; Ok(self) } + /// Set the `Authorization` header to a `Bearer` value with the + /// supplied token. + pub fn bearer_auth(mut self, token: &str) -> Result<Self, curl::Error> { + self.headers.append(&format!("Authorization: Bearer {}", token))?; + Ok(self) + } + /// Add a byte-array body to a request using the specified /// `Content-Type`. pub fn body(mut self, content_type: &'a str, data: &'a [u8]) -> Self { |